Module: Gemmy::Patches::HashPatch::InstanceMethods::ToOpenStruct

Defined in:
lib/gemmy/patches/hash_patch.rb

Instance Method Summary collapse

Instance Method Details

#recursive_to_ostruct(exclude = {}) ⇒ Object



61
62
63
64
65
66
67
68
69
# File 'lib/gemmy/patches/hash_patch.rb', line 61

def recursive_to_ostruct(exclude={})
  return exclude[self] if exclude.key?( self )
  o = exclude[self] = OpenStruct.new
  h = self.dup
  each_pair do |k,v|
    h[k] = v.to_ostruct_recurse( exclude ) if v.respond_to?(:to_ostruct_recurse)
  end
  o.merge!(h)
end

#to_ostructObject

facets



58
59
60
# File 'lib/gemmy/patches/hash_patch.rb', line 58

def to_ostruct
  OpenStruct.new(self)
end