module Nutella::App::Persist
Implements basic app-dependent persistence for app-level components
Public Class Methods
This method returns a JSON-file-backed store (i.e. persistence) for a collection (i.e. an Array) @param [String] name the name of the store @return [JSONFilePersistedCollection] a JSON-file-backed collection store
# File lib/nutella_lib/app_persist.rb, line 35 def self.get_json_collection_store( name ) file_path = "data/#{name}.json" FileUtils.mkdir_p 'data/' JSONFilePersistedCollection.new file_path end
This method returns a JSON-file-backed store (i.e. persistence) for a single object (i.e. an Hash) @param [String] name the name of the store @return [JSONFilePersistedHash] a JSON-file-backed Hash store
# File lib/nutella_lib/app_persist.rb, line 45 def self.get_json_object_store( name ) file_path = "data/#{name}.json" FileUtils.mkdir_p 'data/' JSONFilePersistedHash.new file_path end
This method returns a MongoDB-backed store (i.e. persistence) for a collection (i.e. an Array) @param [String] name the name of the store @return [MongoPersistedCollection] a MongoDB-backed collection store
# File lib/nutella_lib/app_persist.rb, line 19 def self.get_mongo_collection_store( name ) MongoPersistedCollection.new Nutella.mongo_host, Nutella.app_id, name end
This method returns a MongoDB-backed store (i.e. persistence) for a single object (i.e. an Hash) @param [String] name the name of the store @return [MongoPersistedHash] a MongoDB-backed Hash store
# File lib/nutella_lib/app_persist.rb, line 27 def self.get_mongo_object_store( name ) MongoPersistedHash.new Nutella.mongo_host, Nutella.app_id, 'app_persisted_hashes', name end