Sha256: b4236ef977ee3a535ac0efba9966fc2cf749ecdd7c970e79172e75f0957c4fc9
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
module Cockpit class Store class << self attr_accessor :stores def stores @stores ||= {} end def adapter(store) stores[store.name.to_s] ||= {} # unless stores[store.name.to_s].has_key?(store.value.to_s) require 'moneta' stores[store.name.to_s][store.value.to_s] = case store.value.to_s when "mongo", "mongodb" require 'moneta/adapters/mongodb' Moneta::Adapters::MongoDB.new(:collection => store.name) when "active_record" require File.dirname(__FILE__) + '/../moneta/active_record' Moneta::Adapters::ActiveRecord.new(:record => store.scope) when "file" require 'moneta/adapters/basic_file' Moneta::Adapters::BasicFile.new(:path => "./.cockpit") when "redis" require 'moneta/adapters/redis' Moneta::Adapters::Redis.new when "memory" require 'moneta/adapters/memory' Moneta::Adapters::Memory.new when "yaml" require 'moneta/adapters/yaml' Moneta::Adapters::YAML.new end # end stores[store.name.to_s][store.value.to_s] end end attr_reader :name, :value, :scope def initialize(name, value, scope = nil) @name = name @value = value @scope = scope end def adapter self.class.adapter(self) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cockpit-0.1.1 | lib/cockpit/core/store.rb |