Skip to content

Instantly share code, notes, and snippets.

@ayasuda
Created November 25, 2011 08:31
Show Gist options
  • Save ayasuda/1393054 to your computer and use it in GitHub Desktop.
Save ayasuda/1393054 to your computer and use it in GitHub Desktop.
class Hoge
attr_accessor :a
attr_accessor :b
def initialize(initialize_options = {})
defaults = {
:a => "aaaa",
:b => "bbbb"
}
defaults.merge!(initialize_options)
defaults.each do |k ,v|
send((k.to_s + "="), v)
end
end
end
hoge = Hoge.new(:a=>"AAAA")
hoge.a #=> AAAA
hoge.b #=> bbbb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment