Module: Nutella::Framework::Persist
- Defined in:
- lib/nutella_lib/framework_persist.rb
Overview
Implements basic persistence for framework-level components
Framework-level APIs 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).
Run-level APIs collapse
-
.get_run_json_collection_store(app_id, run_id, name) ⇒ JSONFilePersistedCollection
This method returns a JSON-file-backed store for a collection at the run level.
-
.get_run_json_object_store(app_id, run_id, name) ⇒ JSONFilePersistedHash
This method returns a JSON-file-backed store for a single object at the run level.
-
.get_run_mongo_collection_store(app_id, run_id, name) ⇒ MongoPersistedCollection
This method returns a MongoDB-backed store for a collection at the run level.
-
.get_run_mongo_object_store(app_id, run_id, name) ⇒ MongoPersistedHash
This method returns a MongoDB-backed store for a single object at the run level.
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)
37 38 39 40 41 42 |
# File 'lib/nutella_lib/framework_persist.rb', line 37 def self.get_json_collection_store( name ) dir_path = "#{ENV['HOME']}/.nutella/data/#{Nutella.component_id}" file_path = "#{dir_path}/#{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)
48 49 50 51 52 53 |
# File 'lib/nutella_lib/framework_persist.rb', line 48 def self.get_json_object_store( name ) dir_path = "#{ENV['HOME']}/.nutella/data/#{Nutella.component_id}" file_path = "#{dir_path}/#{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)
21 22 23 |
# File 'lib/nutella_lib/framework_persist.rb', line 21 def self.get_mongo_collection_store( name ) MongoPersistedCollection.new Nutella.mongo_host, 'nutella', name 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)
29 30 31 |
# File 'lib/nutella_lib/framework_persist.rb', line 29 def self.get_mongo_object_store( name ) MongoPersistedHash.new Nutella.mongo_host, 'nutella', 'fr_persisted_hashes', name end |
.get_run_json_collection_store(app_id, run_id, name) ⇒ JSONFilePersistedCollection
This method returns a JSON-file-backed store for a collection at the run level
99 100 101 102 103 104 |
# File 'lib/nutella_lib/framework_persist.rb', line 99 def self.get_run_json_collection_store( app_id, run_id, name ) dir_path = "#{ENV['HOME']}/.nutella/data/#{Nutella.component_id}/#{app_id}/#{run_id}" file_path = "#{dir_path}/#{name}.json" FileUtils.mkdir_p dir_path JSONFilePersistedCollection.new file_path end |
.get_run_json_object_store(app_id, run_id, name) ⇒ JSONFilePersistedHash
This method returns a JSON-file-backed store for a single object at the run level
112 113 114 115 116 117 |
# File 'lib/nutella_lib/framework_persist.rb', line 112 def self.get_run_json_object_store( app_id, run_id, name ) dir_path = "#{ENV['HOME']}/.nutella/data/#{Nutella.component_id}/#{app_id}/#{run_id}" file_path = "#{dir_path}/#{name}.json" FileUtils.mkdir_p dir_path JSONFilePersistedHash.new file_path end |
.get_run_mongo_collection_store(app_id, run_id, name) ⇒ MongoPersistedCollection
This method returns a MongoDB-backed store for a collection at the run level
67 68 69 70 71 72 73 74 75 |
# File 'lib/nutella_lib/framework_persist.rb', line 67 def self.get_run_mongo_collection_store( app_id, run_id, name ) if @run_stores.nil? @run_stores = {} end unless @run_stores.include? [app_id, run_id, name] @run_stores[[app_id, run_id, name]] = MongoPersistedCollection.new Nutella.mongo_host, app_id, "#{run_id}/#{name}" end @run_stores[[app_id, run_id, name]] end |
.get_run_mongo_object_store(app_id, run_id, name) ⇒ MongoPersistedHash
This method returns a MongoDB-backed store for a single object at the run level
83 84 85 86 87 88 89 90 91 |
# File 'lib/nutella_lib/framework_persist.rb', line 83 def self.get_run_mongo_object_store( app_id, run_id, name ) if @run_stores.nil? @run_stores = {} end unless @run_stores.include? [app_id, run_id, name] @run_stores[[app_id, run_id, name]] = MongoPersistedHash.new Nutella.mongo_host, app_id, 'run_persisted_hashes', "#{run_id}/#{name}" end @run_stores[[app_id, run_id, name]] end |