Class: CacheToolbox::Multistore
- Inherits:
-
ActiveSupport::Cache::Store
- Object
- ActiveSupport::Cache::Store
- CacheToolbox::Multistore
- Defined in:
- lib/cache_toolbox/multistore.rb
Overview
nodoc #
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Multistore
constructor
A new instance of Multistore.
Constructor Details
#initialize(options = {}) ⇒ Multistore
Returns a new instance of Multistore.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/cache_toolbox/multistore.rb', line 9 def initialize( = {}) super() raise ArgumentError, 'Specify default store argument default: :{store name}' unless .key?(:default) && [:default].is_a?(Symbol) raise ArgumentError, 'Specify store list argument stores: {...}' unless .key?(:stores) @default = [:default] @stores = [:stores].map do |name, store| [name, ::ActiveSupport::Cache.lookup_store(store)] end.to_h @stores[:default] = @stores[[:default]] # TODO: check if @stores[@default] exists end |