Module: Nutella::Persist
- Defined in:
- lib/nutella_lib/persist.rb
Overview
Implements basic run-dependent persistence for run-level components
Class Method Summary collapse
-
.get_json_collection_store(name) ⇒ JSONFilePersistedCollection
This method returns a JSON-file-backed store (i.e. persistence) for a collection (i.e. an Array).
-
.get_json_object_store(name) ⇒ JSONFilePersistedHash
This method returns a JSON-file-backed store (i.e. persistence) for a single object (i.e. an Hash).
-
.get_mongo_collection_store(name) ⇒ MongoPersistedCollection
This method returns a MongoDB-backed store (i.e. persistence) for a collection (i.e. an Array).
-
.get_mongo_object_store(name) ⇒ MongoPersistedHash
This method returns a MongoDB-backed store (i.e. persistence) for a single object (i.e. an Hash).
Class Method Details
.get_json_collection_store(name) ⇒ JSONFilePersistedCollection
This method returns a JSON-file-backed store (i.e. persistence) for a collection (i.e. an Array)
35 36 37 38 39 40 |
# File 'lib/nutella_lib/persist.rb', line 35 def self.get_json_collection_store( name ) dir_path = "data/#{Nutella.run_id}" file_path = "data/#{Nutella.run_id}/#{name}.json" FileUtils.mkdir_p dir_path JSONFilePersistedCollection.new file_path end |
.get_json_object_store(name) ⇒ JSONFilePersistedHash
This method returns a JSON-file-backed store (i.e. persistence) for a single object (i.e. an Hash)
46 47 48 49 50 51 |
# File 'lib/nutella_lib/persist.rb', line 46 def self.get_json_object_store( name ) dir_path = "data/#{Nutella.run_id}" file_path = "data/#{Nutella.run_id}/#{name}.json" FileUtils.mkdir_p dir_path JSONFilePersistedHash.new file_path end |
.get_mongo_collection_store(name) ⇒ MongoPersistedCollection
This method returns a MongoDB-backed store (i.e. persistence) for a collection (i.e. an Array)
17 18 19 20 |
# File 'lib/nutella_lib/persist.rb', line 17 def self.get_mongo_collection_store( name ) collection = "#{Nutella.run_id}/#{name}" MongoPersistedCollection.new Nutella.mongo_host, Nutella.app_id, collection end |
.get_mongo_object_store(name) ⇒ MongoPersistedHash
This method returns a MongoDB-backed store (i.e. persistence) for a single object (i.e. an Hash)
26 27 28 29 |
# File 'lib/nutella_lib/persist.rb', line 26 def self.get_mongo_object_store( name ) doc_id = "#{Nutella.run_id}/#{name}" MongoPersistedHash.new Nutella.mongo_host, Nutella.app_id, 'run_persisted_hashes', doc_id end |