Class: RemoteResource::Storage::Memory
- Inherits:
-
Object
- Object
- RemoteResource::Storage::Memory
- Defined in:
- lib/remote_resource/storage/memory.rb
Instance Attribute Summary collapse
-
#memory_value ⇒ Object
Returns the value of attribute memory_value.
Instance Method Summary collapse
-
#initialize ⇒ Memory
constructor
A new instance of Memory.
- #read_key(key) ⇒ Object
- #write_key(key, storage_entry) ⇒ Object
Constructor Details
#initialize ⇒ Memory
Returns a new instance of Memory.
8 9 10 |
# File 'lib/remote_resource/storage/memory.rb', line 8 def initialize @memory_value = {} end |
Instance Attribute Details
#memory_value ⇒ Object
Returns the value of attribute memory_value.
6 7 8 |
# File 'lib/remote_resource/storage/memory.rb', line 6 def memory_value @memory_value end |
Instance Method Details
#read_key(key) ⇒ Object
12 13 14 15 16 |
# File 'lib/remote_resource/storage/memory.rb', line 12 def read_key(key) value = @memory_value[key] return nil unless value.is_a? Hash StorageEntry.new(value[:headers], value[:data]) end |
#write_key(key, storage_entry) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/remote_resource/storage/memory.rb', line 18 def write_key(key, storage_entry) if @memory_value[key] @memory_value[key].merge!(storage_entry.to_hash) else @memory_value[key] = storage_entry.to_hash end end |