Class: SimpleJSONSchema::Cache
- Inherits:
-
Object
- Object
- SimpleJSONSchema::Cache
- Defined in:
- lib/simple_json_schema/cache.rb
Instance Attribute Summary collapse
-
#memory ⇒ Object
readonly
Returns the value of attribute memory.
Instance Method Summary collapse
- #fetch(key) ⇒ Object
-
#initialize ⇒ Cache
constructor
A new instance of Cache.
Constructor Details
#initialize ⇒ Cache
Returns a new instance of Cache.
7 8 9 |
# File 'lib/simple_json_schema/cache.rb', line 7 def initialize @memory = {} end |
Instance Attribute Details
#memory ⇒ Object (readonly)
Returns the value of attribute memory.
5 6 7 |
# File 'lib/simple_json_schema/cache.rb', line 5 def memory @memory end |
Instance Method Details
#fetch(key) ⇒ Object
11 12 13 |
# File 'lib/simple_json_schema/cache.rb', line 11 def fetch(key) memory[key] ||= yield end |