Class: BackgroundQueue::Utils::AnyKeyHash
- Inherits:
-
Object
- Object
- BackgroundQueue::Utils::AnyKeyHash
- Defined in:
- lib/background_queue/utils.rb
Overview
class that wraps a hash so it can be accessed by key or symbol
Instance Attribute Summary collapse
-
#hash ⇒ Object
the wrapped hash.
Instance Method Summary collapse
-
#[](key) ⇒ Object
get an entry by string or symbol.
- #[]=(key, value) ⇒ Object
-
#initialize(hash) ⇒ AnyKeyHash
constructor
wrap a hash.
- #to_json(dummy = true) ⇒ Object
Constructor Details
#initialize(hash) ⇒ AnyKeyHash
wrap a hash
22 23 24 |
# File 'lib/background_queue/utils.rb', line 22 def initialize(hash) @hash = hash end |
Instance Attribute Details
#hash ⇒ Object
the wrapped hash
19 20 21 |
# File 'lib/background_queue/utils.rb', line 19 def hash @hash end |
Instance Method Details
#[](key) ⇒ Object
get an entry by string or symbol
27 28 29 |
# File 'lib/background_queue/utils.rb', line 27 def [] (key) BackgroundQueue::Utils.get_hash_entry(@hash, key) end |
#[]=(key, value) ⇒ Object
31 32 33 |
# File 'lib/background_queue/utils.rb', line 31 def []=(key, value) @hash[key] = value end |
#to_json(dummy = true) ⇒ Object
35 36 37 |
# File 'lib/background_queue/utils.rb', line 35 def to_json(dummy=true) @hash.to_json end |