Class: Houston::ReadonlyHash

Inherits:
Object
  • Object
show all
Defined in:
lib/houston/boot/observer.rb

Direct Known Subclasses

Actions::ExecutionContext

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ ReadonlyHash

Returns a new instance of ReadonlyHash.



144
145
146
147
148
149
# File 'lib/houston/boot/observer.rb', line 144

def initialize(hash)
  @hash = hash.symbolize_keys
  @hash.keys.each do |key|
    define_singleton_method(key) { @hash[key] }
  end
end

Instance Method Details

#[](key) ⇒ Object



151
152
153
# File 'lib/houston/boot/observer.rb', line 151

def [](key)
  @hash[key.to_sym]
end

#countObject



155
156
157
# File 'lib/houston/boot/observer.rb', line 155

def count
  @hash.count
end

#to_hObject



159
160
161
# File 'lib/houston/boot/observer.rb', line 159

def to_h
  @hash.dup
end