Class: Moneta::Adapter
- Inherits:
-
Object
- Object
- Moneta::Adapter
- Defined in:
- lib/moneta/adapter.rb
Overview
Adapter base class
Direct Known Subclasses
Moneta::Adapters::ActiveRecord, Moneta::Adapters::ActiveSupportCache, Moneta::Adapters::Cassandra, Moneta::Adapters::Client, Moneta::Adapters::Couch, Moneta::Adapters::DBM, Moneta::Adapters::Daybreak, Moneta::Adapters::Fog, Moneta::Adapters::GDBM, Moneta::Adapters::HBase, Moneta::Adapters::KyotoCabinet, Moneta::Adapters::LMDB, Moneta::Adapters::LRUHash, Moneta::Adapters::LevelDB, Moneta::Adapters::LocalMemCache, Moneta::Adapters::MemcachedDalli, Moneta::Adapters::MemcachedNative, Moneta::Adapters::Memory, Moneta::Adapters::Mongo, Moneta::Adapters::PStore, Moneta::Adapters::Redis, Moneta::Adapters::RestClient, Moneta::Adapters::Riak, Moneta::Adapters::SDBM, Moneta::Adapters::Sequel, Moneta::Adapters::Sqlite, Moneta::Adapters::TDB, Moneta::Adapters::TokyoCabinet, Moneta::Adapters::TokyoTyrant
Instance Attribute Summary collapse
- #backend ⇒ Object readonly
Class Method Summary collapse
-
.backend(required: true) {|**options| ... } ⇒ Object
Define a block used to build this adapter’s backend.
- .backend_block ⇒ Object
- .backend_required? ⇒ Boolean
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Adapter
constructor
A new instance of Adapter.
Methods included from Config
Methods included from Defaults
#[], #[]=, #close, #create, #decrement, #each_key, #features, #fetch, #fetch_values, included, #increment, #key?, #merge!, #slice, #supports?, #update, #values_at
Methods included from OptionSupport
#expires, #prefix, #raw, #with
Constructor Details
#initialize(options = {}) ⇒ Adapter
Returns a new instance of Adapter.
37 38 39 |
# File 'lib/moneta/adapter.rb', line 37 def initialize( = {}) set_backend(**configure(**)) end |
Instance Attribute Details
#backend ⇒ Object (readonly)
8 9 10 |
# File 'lib/moneta/adapter.rb', line 8 def backend @backend end |
Class Method Details
.backend(required: true) {|**options| ... } ⇒ Object
Define a block used to build this adapter’s backend. The block will receive as keyword arguments any options passed to the adapter during initialization that are not config settings.
If the adapter is initialized with a ‘:backend` option, this will be used instead, and the block won’t be called.
21 22 23 24 25 |
# File 'lib/moneta/adapter.rb', line 21 def backend(required: true, &block) raise "backend block already set" if class_variables(false).include?(:@@backend_block) class_variable_set(:@@backend_block, block) class_variable_set(:@@backend_required, true) if required end |
.backend_block ⇒ Object
27 28 29 |
# File 'lib/moneta/adapter.rb', line 27 def backend_block class_variable_get(:@@backend_block) if class_variable_defined?(:@@backend_block) end |
.backend_required? ⇒ Boolean
31 32 33 |
# File 'lib/moneta/adapter.rb', line 31 def backend_required? class_variable_defined?(:@@backend_required) end |