Class: Excursion::Datastores::File
- Defined in:
- lib/excursion/datastores/file.rb
Instance Method Summary collapse
- #all ⇒ Object
- #delete(key) ⇒ Object (also: #unset)
- #read(key) ⇒ Object (also: #get)
- #write(key, value) ⇒ Object (also: #set)
Methods inherited from Datastore
Instance Method Details
#all ⇒ Object
29 30 31 |
# File 'lib/excursion/datastores/file.rb', line 29 def all HashWithIndifferentAccess.new(read_file) end |
#delete(key) ⇒ Object Also known as: unset
21 22 23 24 25 26 |
# File 'lib/excursion/datastores/file.rb', line 21 def delete(key) current = read_file deleted = current.delete(key.to_s) write_file(current) deleted end |
#read(key) ⇒ Object Also known as: get
8 9 10 |
# File 'lib/excursion/datastores/file.rb', line 8 def read(key) read_file[key.to_s] end |
#write(key, value) ⇒ Object Also known as: set
13 14 15 16 17 18 |
# File 'lib/excursion/datastores/file.rb', line 13 def write(key, value) current = read_file current[key.to_s] = value write_file(current) current[key.to_s] end |