Method: Rstruct::Structure#instance
- Defined in:
- lib/rstruct/structure.rb
#instance(values = nil) {|s| ... } ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rstruct/structure.rb', line 30 def instance(values=nil) values ||= {} vals = [] self.fields.each do |f| v = values[f.name] vals << (f.typ.respond_to?(:instance) ? f.typ.instance(v) : v) end s = @mystruct.new(*vals).extend(ContainerMixins) s.rstruct_type = self yield(s) if block_given? return s end |