Class: TypedStruct
Class Method Summary collapse
Class Method Details
.new(*members_types) ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/wukong/typed_struct.rb', line 2 def self.new *members_types members, mtypes = members_types.transpose klass = Struct.new *members.map(&:to_sym) klass.class_eval do cattr_accessor :mtypes, :members_types self.mtypes = mtypes self.members_types = Hash.zip(members, mtypes) end klass end |