Class: Sc4ry::Store
- Inherits:
-
Object
- Object
- Sc4ry::Store
- Extended by:
- Forwardable
- Includes:
- Singleton
- Defined in:
- lib/sc4ry/store.rb
Constant Summary collapse
- @@current =
:memory- @@backends =
{:memory => {:class => Sc4ry::Backends::Memory}, :redis => {:class => Sc4ry::Backends::Redis, :config => {:host => 'localhost', :port => 6379, :db => 10 }}}
Instance Attribute Summary collapse
-
#be ⇒ Object
readonly
Returns the value of attribute be.
Instance Method Summary collapse
- #change_backend(options) ⇒ Object
- #config_backend(options) ⇒ Object
- #current ⇒ Object
-
#initialize ⇒ Store
constructor
A new instance of Store.
- #register_backend(options) ⇒ Object
Constructor Details
#initialize ⇒ Store
Returns a new instance of Store.
15 16 17 |
# File 'lib/sc4ry/store.rb', line 15 def initialize change_backend name: @@current end |
Instance Attribute Details
#be ⇒ Object (readonly)
Returns the value of attribute be.
12 13 14 |
# File 'lib/sc4ry/store.rb', line 12 def be @be end |
Instance Method Details
#change_backend(options) ⇒ Object
23 24 25 26 |
# File 'lib/sc4ry/store.rb', line 23 def change_backend() @@current = [:name] @be = @@backends[@@current][:class]::new(@@backends[@@current][:config]) end |
#config_backend(options) ⇒ Object
34 35 36 37 38 |
# File 'lib/sc4ry/store.rb', line 34 def config_backend() raise ":name is mandatory" unless [:name] raise ":config is mandatory" unless [:config] @@backends[[:name]][:config] = [:config] end |
#current ⇒ Object
19 20 21 |
# File 'lib/sc4ry/store.rb', line 19 def current return @@current end |
#register_backend(options) ⇒ Object
28 29 30 31 32 |
# File 'lib/sc4ry/store.rb', line 28 def register_backend() raise ":name is mandatory" unless [:name] raise ":definition is mandatory" unless [:definition] @@backends[[:name]] = [:definition] end |