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.



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

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



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

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

#countObject



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

def count
  @hash.count
end

#to_hObject



164
165
166
# File 'lib/houston/boot/observer.rb', line 164

def to_h
  @hash.dup
end