class Setting

Public Class Methods

new(hash = {}) click to toggle source
# File lib/rails_com/utils/setting.rb, line 3
def initialize(hash = {})
  @table = {}
  @hash_table = {}

  hash.each do |k, v|
    if v.is_a?(Hash)
      @table[k.to_sym] = self.class.new(v)
    elsif v.is_a?(Array)
      @table[k.to_sym] = v.map { |h| h.is_a?(Hash) ? self.class.new(h) : h }
    else
      @table[k.to_sym] = v
    end
    @hash_table[k.to_sym] = v
    new_ostruct_member(k)
  end
end

Public Instance Methods

to_hash() click to toggle source
# File lib/rails_com/utils/setting.rb, line 20
def to_hash
  @hash_table.with_indifferent_access
end