Class: Cockpit::Store
- Inherits:
-
Object
- Object
- Cockpit::Store
- Defined in:
- lib/cockpit/core/store.rb
Class Attribute Summary collapse
-
.stores ⇒ Object
Returns the value of attribute stores.
Class Method Summary collapse
- .find(name) ⇒ Object
- .store(name) ⇒ Object
- .store?(name) ⇒ Boolean
- .support(name) ⇒ Object
- .use(options) ⇒ Object
Class Attribute Details
.stores ⇒ Object
Returns the value of attribute stores.
4 5 6 |
# File 'lib/cockpit/core/store.rb', line 4 def stores @stores end |
Class Method Details
.find(name) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cockpit/core/store.rb', line 6 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 |
.store(name) ⇒ Object
38 39 40 |
# File 'lib/cockpit/core/store.rb', line 38 def store(name) stores[name.to_sym] end |
.store?(name) ⇒ Boolean
42 43 44 |
# File 'lib/cockpit/core/store.rb', line 42 def store?(name) stores.has_key?(name.to_sym) end |
.support(name) ⇒ Object
30 31 32 |
# File 'lib/cockpit/core/store.rb', line 30 def support(name) eval("::#{find(name)}::Support".gsub(/::[:]+/, "::")) end |
.use(options) ⇒ Object
26 27 28 |
# File 'lib/cockpit/core/store.rb', line 26 def use() eval("::#{find([:store])}::Store".gsub(/::[:]+/, "::")).new([:record], [:name]) end |