Class: Phobos::DeepStruct

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/phobos/deep_struct.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash = nil) ⇒ DeepStruct



10
11
12
13
14
15
16
17
18
19
# File 'lib/phobos/deep_struct.rb', line 10

def initialize(hash = nil)
  @table = {}
  @hash_table = {}

  hash&.each_pair do |key, value|
    key = key.to_sym
    @table[key] = to_deep_struct(value)
    @hash_table[key] = value
  end
end

Instance Method Details

#to_hObject Also known as: to_hash



21
22
23
# File 'lib/phobos/deep_struct.rb', line 21

def to_h
  @hash_table.dup
end