class OpenHash
OpenHash¶ ↑
OpenHash is akin to an OpenStruct or an OpenObject, but it is much simplier in nature. It is a hash with an #method_missing definition that routes to [] and []=.
Public Class Methods
new(data)
click to toggle source
New OpenHash.
Calls superclass method
# File lib/more/facets/openhash.rb, line 22 def initialize(data) super() update(data) end
Public Instance Methods
method_missing(s, *a)
click to toggle source
Route get and set calls.
Calls superclass method
Object#method_missing
# File lib/more/facets/openhash.rb, line 29 def method_missing(s, *a) if s =~ /=$/ self[s] = a[0] elsif a.empty? self[s] else super end end