Class: SimpleJSONSchema::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_json_schema/cache.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCache

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

#memoryObject (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