Class: SolidStruct::NamedStruct

Inherits:
Struct
  • Object
show all
Defined in:
lib/solid_struct.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ NamedStruct

Override the initialize to handle hashes of named parameters



7
8
9
10
11
12
13
# File 'lib/solid_struct.rb', line 7

def initialize *args
  opts = args.last.is_a?(Hash) ? args.pop : Hash.new
  super *args
  opts.each_pair do |k, v|
    self.send "#{k}=", v
  end
end