Class OpenStruct
In: lib/facets/core/ostruct/instance_delegate.rb
lib/facets/core/ostruct/__update__.rb
lib/facets/core/ostruct/__table__.rb
lib/facets/core/ostruct/op_fetch.rb
lib/facets/core/ostruct/to_h.rb
Parent: Object

Methods

[]   []=   __merge__   __table__   __update__   instance_delegate   to_h  

Public Instance methods

Access a value in the OpenStruct by key, like a Hash. This increases OpenStruct‘s "duckiness".

  o = OpenStruct.new
  o.t = 4
  o['t']  #=> 4

Set a value in the OpenStruct by key, like a Hash.

  o = OpenStruct.new
  o['t'] = 4
  o.t  #=> 4

Merge hash data creating a new OpenStruct object.

  o = OpenStruct.new
  o.ostruct_merge { :a => 2 }
  o.a  #=> 2

Provides public access to the inner table.

Insert/update hash data on the fly.

  o = OpenStruct.new
  o.ostruct_update { :a => 2 }
  o.a  #=> 2

Provides access to an OpenStruct‘s inner table.

  o = OpenStruct.new
  o.a = 1
  o.b = 2
  o.instance_delegate.each { |k, v| puts "#{k} #{v}" }

produces

  a 1
  b 2

[Validate]