Class: Genghis::HashWithConsistentAccess
- Inherits:
-
Object
- Object
- Genghis::HashWithConsistentAccess
- Defined in:
- lib/genghis.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #each_pair(&block) ⇒ Object
-
#initialize(proxied = {}) ⇒ HashWithConsistentAccess
constructor
A new instance of HashWithConsistentAccess.
- #inspect ⇒ Object
- #key?(key) ⇒ Boolean
Constructor Details
#initialize(proxied = {}) ⇒ HashWithConsistentAccess
Returns a new instance of HashWithConsistentAccess.
235 236 237 238 239 240 |
# File 'lib/genghis.rb', line 235 def initialize(proxied={}) @proxied = proxied.inject({}) do |memo, (k, v)| memo[k.to_s] = v memo end end |
Instance Method Details
#[](key) ⇒ Object
252 253 254 |
# File 'lib/genghis.rb', line 252 def [](key) @proxied[key.to_s] end |
#[]=(key, value) ⇒ Object
248 249 250 |
# File 'lib/genghis.rb', line 248 def []=(key, value) @proxied[key.to_s] = value end |
#each_pair(&block) ⇒ Object
242 243 244 245 246 |
# File 'lib/genghis.rb', line 242 def each_pair(&block) @proxied.each_pair do |k, v| yield(k.to_s, v) end end |
#inspect ⇒ Object
260 261 262 |
# File 'lib/genghis.rb', line 260 def inspect @proxied.inspect end |
#key?(key) ⇒ Boolean
256 257 258 |
# File 'lib/genghis.rb', line 256 def key?(key) @proxied.key?(key.to_s) end |