class DeepStruct

Public Class Methods

new(hash=nil) click to toggle source
# File lib/twitchy/dstruct.rb, line 4
def initialize(hash=nil)
  @table = {}
  @hash_table = {}

  if hash
    hash.each do |k,v|
      @table[k.to_sym] = v

      @table[k.to_sym] = v.map do |o|
          o.is_a?(Hash) ? self.class.new(o) : o
      end if v.is_a? Array

      @table[k.to_sym] = self.class.new(v) if v.is_a? Hash

      @hash_table[k.to_sym] = v

      new_ostruct_member(k)
    end
  end
end

Public Instance Methods

to_h() click to toggle source
# File lib/twitchy/dstruct.rb, line 25
def to_h
  @hash_table
end