Class: MoreOpenStruct

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/helpers/hash_helpers.rb,
lib/helpers/old_more_open_struct.rb

Instance Method Summary collapse

Instance Method Details

#_manual_set(hash) ⇒ Object



66
67
68
69
70
71
72
73
# File 'lib/helpers/hash_helpers.rb', line 66

def _manual_set(hash)
  if hash && (hash.class == Hash)
    for k,v in hash
      @table[k.to_sym] = v
      new_ostruct_member(k)
    end
  end
end

#_tableObject



62
63
64
# File 'lib/helpers/hash_helpers.rb', line 62

def _table
  @table   #table is the hash structure used in OpenStruct
end

#_to_hashObject



51
52
53
54
55
56
57
58
59
60
# File 'lib/helpers/hash_helpers.rb', line 51

def _to_hash
  h = @table
  #handles nested structures
  h.each do |k,v|
    if v.class == MoreOpenStruct
      h[k] = v._to_hash
    end
  end
  return h
end