Module: JsonSpec::Memory
- Included in:
- JsonSpec
- Defined in:
- lib/json_spec/memory.rb
Instance Method Summary collapse
Instance Method Details
#forget ⇒ Object
16 17 18 |
# File 'lib/json_spec/memory.rb', line 16 def forget memory.clear end |
#memorize(key, value) ⇒ Object
7 8 9 |
# File 'lib/json_spec/memory.rb', line 7 def memorize(key, value) memory[key] = value end |
#memory ⇒ Object
3 4 5 |
# File 'lib/json_spec/memory.rb', line 3 def memory @memory ||= {} end |
#remember(json) ⇒ Object
11 12 13 14 |
# File 'lib/json_spec/memory.rb', line 11 def remember(json) return json if memory.empty? json.gsub(/%\{(#{memory.keys.map{|k| Regexp.quote(k) }.join("|")})\}/){ memory[$1] } end |