Skip to content

Instantly share code, notes, and snippets.

@timmatheson
Created February 9, 2010 01:50
Show Gist options
  • Save timmatheson/298842 to your computer and use it in GitHub Desktop.
Save timmatheson/298842 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
class Foo
attr_accessor :name, :age
def initialize
@options = {:name => "Tim", :age => 28}
end
def work(h)
@options.merge!(h).each do |k,v|
self.instance_variable_set(:"@#{k}",v)
end
end
end
f = Foo.new
f.work(:age => 30)
puts f.age
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment