Class: Wikidata::IdentityMap
Instance Attribute Summary
Attributes inherited from HashedObject
#data_hash
Class Method Summary
collapse
#initialize, #method_missing
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Wikidata::HashedObject
Class Method Details
.cache!(key, value) ⇒ Object
17
18
19
20
|
# File 'lib/wikidata/identity_map.rb', line 17
def self.cache!(key, value)
@@identity_map ||= {}
@@identity_map[key] = value
end
|
.cached_value(key) ⇒ Object
12
13
14
15
|
# File 'lib/wikidata/identity_map.rb', line 12
def self.cached_value(key)
@@identity_map ||= {}
@@identity_map[key]
end
|
.if_uncached(key, &block) ⇒ Object
4
5
6
7
8
9
10
|
# File 'lib/wikidata/identity_map.rb', line 4
def self.if_uncached(key, &block)
if cached = cached_value(key)
return cached
else
block.call
end
end
|