Sha256: 152370fee938ee3488f3f03ae33de7fc75ba3f62ae825eba0a0682c712bbe80e
Contents?: true
Size: 1.04 KB
Versions: 9
Compression:
Stored size: 1.04 KB
Contents
module Cockpit class Store class << self attr_accessor :stores def find(name) return store(name) if store?(name) base_path = "#{File.dirname(__FILE__)}/../stores" @stores[name.to_sym] = case name.to_sym when :active_record require "#{base_path}/active_record" "::Cockpit::AR" when :mongo require "#{base_path}/mongo" "::Cockpit::Mongo" else require "#{base_path}/memory" "::Cockpit::Memory" end store(name) end def use(options) eval("::#{find(options[:store])}::Store".gsub(/::[:]+/, "::")).new(options[:record], options[:name]) end def support(name) eval("::#{find(name)}::Support".gsub(/::[:]+/, "::")) end def stores @stores ||= {} end def store(name) stores[name.to_sym] end def store?(name) stores.has_key?(name.to_sym) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems