Module: Polist::Struct::ClassMethods
- Defined in:
- lib/polist/struct.rb
Instance Method Summary collapse
Instance Method Details
#struct(*attrs) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/polist/struct.rb', line 6 def struct(*attrs) attr_accessor(*attrs) define_method(:initialize) do |*args| raise ArgumentError, "struct size differs" if args.length > attrs.length attrs.zip(args).each { |attr, val| public_send(:"#{attr}=", val) } end end |