class DeepOpenStruct

Public Class Methods

new(hash = nil) click to toggle source
# File lib/dominate/inflectors.rb, line 25
def initialize hash = nil

  @table = {}
  @hash_table = {}

  hash = [hash] unless hash.is_a? Hash

  if hash
    hash.each do |k,v|

      if v.is_a? Array
        @table[k.to_sym] ||= []
        @hash_table[k.to_sym] ||= []

        v.each { | entry |
          @table[k.to_sym] << entry
          @hash_table[k.to_sym] << entry
        }
      else
        @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
end

Public Instance Methods

to_h() click to toggle source
# File lib/dominate/inflectors.rb, line 52
def to_h
  @hash_table
end