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.
107 108 109 |
# File 'lib/valkyrie/persistence/fedora/ordered_list.rb', line 107 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
115 116 117 |
# File 'lib/valkyrie/persistence/fedora/ordered_list.rb', line 115 def fetch(uri) @cache[uri] ||= yield if block_given? end |
#key?(key) ⇒ Boolean
Determines whether or not the cache contains a key
122 123 124 |
# File 'lib/valkyrie/persistence/fedora/ordered_list.rb', line 122 def key?(key) @cache.key?(key) end |