Class: AudioBookCreator::CachedHash

Inherits:
Object
  • Object
show all
Defined in:
lib/audio_book_creator/cached_hash.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cache, main) ⇒ CachedHash

Returns a new instance of CachedHash.



11
12
13
14
# File 'lib/audio_book_creator/cached_hash.rb', line 11

def initialize(cache, main)
  @cache = cache
  @main  = main
end

Instance Attribute Details

#cacheObject

Returns the value of attribute cache.



5
6
7
# File 'lib/audio_book_creator/cached_hash.rb', line 5

def cache
  @cache
end

#caching layer(layer) ⇒ Object



5
# File 'lib/audio_book_creator/cached_hash.rb', line 5

attr_accessor :cache

#mainObject

Returns the value of attribute main.



9
10
11
# File 'lib/audio_book_creator/cached_hash.rb', line 9

def main
  @main
end

#main hash(hash) ⇒ Object



9
# File 'lib/audio_book_creator/cached_hash.rb', line 9

attr_accessor :main

Instance Method Details

#[](name) ⇒ Object



16
17
18
# File 'lib/audio_book_creator/cached_hash.rb', line 16

def [](name)
  @cache[name] ||= main[name]
end