Class: Facy::DeepStruct

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/facy/converter.rb

Direct Known Subclasses

Item

Instance Method Summary collapse

Constructor Details

#initialize(hash = nil) ⇒ DeepStruct

Returns a new instance of DeepStruct.



74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/facy/converter.rb', line 74

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

  if hash
    hash.each do |k,v|
      @table[k.to_sym] = (v.is_a?(Hash) ? self.class.new(v) : v)
      @hash_table[k.to_sym] = v
      new_ostruct_member(k)
    end
  end 
end

Instance Method Details

#to_hObject



87
88
89
# File 'lib/facy/converter.rb', line 87

def to_h
  @hash_table
end