Class: Moneta::Fallback
Overview
Provides a fallback to a second store when an exception is raised
Instance Attribute Summary
Attributes inherited from Proxy
Instance Method Summary collapse
-
#initialize(adapter, options = {}, &block) ⇒ Fallback
constructor
A new instance of Fallback.
Methods inherited from Wrapper
#clear, #close, #create, #delete, #each_key, #features, #fetch_values, #increment, #key?, #load, #merge!, #slice, #store, #values_at
Methods inherited from Proxy
#clear, #close, #create, #delete, #each_key, #features, features_mask, #fetch_values, #increment, #key?, #load, #merge!, not_supports, #slice, #store, #values_at
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(adapter, options = {}, &block) ⇒ Fallback
Returns a new instance of Fallback.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/moneta/fallback.rb', line 34 def initialize(adapter, = {}, &block) super @fallback = if block_given? ::Moneta.build(&block) elsif .key?(:fallback) .delete(:fallback) else ::Moneta::Adapters::Null.new end @rescue = case [:rescue] when nil [::IOError] when Array [:rescue] else [[:rescue]] end end |