Class: Valkyrie::Persistence::Fedora::OrderedList::NodeCache
- Inherits:
-
Object
- Object
- Valkyrie::Persistence::Fedora::OrderedList::NodeCache
- Defined in:
- lib/valkyrie/persistence/fedora/ordered_list.rb
Overview
Class used for caching LinkedNode objects mapped to URIs
Instance Method Summary collapse
-
#fetch(uri) ⇒ ListNode
Retrieve the ListNode for a given URI If a block is passed, set its output to the cache.
-
#initialize ⇒ NodeCache
constructor
A new instance of NodeCache.
-
#key?(key) ⇒ Boolean
Determines whether or not the cache contains a key.
Constructor Details
#initialize ⇒ NodeCache
Returns a new instance of NodeCache.
109 110 111 |
# File 'lib/valkyrie/persistence/fedora/ordered_list.rb', line 109 def initialize @cache ||= {} end |
Instance Method Details
#fetch(uri) ⇒ ListNode
Retrieve the ListNode for a given URI If a block is passed, set its output to the cache
117 118 119 |
# File 'lib/valkyrie/persistence/fedora/ordered_list.rb', line 117 def fetch(uri) @cache[uri] ||= yield if block_given? end |
#key?(key) ⇒ Boolean
Determines whether or not the cache contains a key
124 125 126 |
# File 'lib/valkyrie/persistence/fedora/ordered_list.rb', line 124 def key?(key) @cache.key?(key) end |