require 'yaml' class Test def hello p @a end end test = nil YAML.load_documents(File.read('test.yaml')) do |doc| test = doc end p test test.hello