Class: BackgroundQueue::Utils::AnyKeyHash

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#hashObject

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