Module: Struct::For_Pairs::ClassMethods

Included in:
Struct
Defined in:
lib/struct/for_pairs/classmethods.rb

Instance Method Summary collapse

Instance Method Details

#for_pairs(pairs) ⇒ Struct

Returns new instance

Parameters:

  • pairs (Hash, Struct, #each_pair)
    • nameA => valueX

Returns:


9
10
11
# File 'lib/struct/for_pairs/classmethods.rb', line 9

def for_pairs(pairs)
  new(*pairs.keys.map(&:to_sym)).for_pairs pairs
end

#inherited(cls) ⇒ Object (private)


15
16
17
18
# File 'lib/struct/for_pairs/classmethods.rb', line 15

def inherited(cls)
  super
  cls.extend For_Pairs::SubclassClassMethods
end