Class: Moneta::OptionMerger Private
- Defined in:
- lib/moneta/optionmerger.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- METHODS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
[:key?, :load, :store, :create, :delete, :increment, :clear].freeze
Instance Attribute Summary collapse
- #default_options ⇒ Object readonly private
Attributes inherited from Proxy
Instance Method Summary collapse
-
#initialize(adapter, options = {}) ⇒ OptionMerger
constructor
private
A new instance of OptionMerger.
Methods inherited from Wrapper
#clear, #close, #config, #create, #delete, #each_key, #features, #fetch_values, #increment, #key?, #load, #merge!, #slice, #store, #values_at
Methods inherited from Proxy
#clear, #close, #config, #create, #delete, #each_key, #features, features_mask, #fetch_values, #increment, #key?, #load, #merge!, not_supports, #slice, #store, #values_at
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(adapter, options = {}) ⇒ OptionMerger
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of OptionMerger.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/moneta/optionmerger.rb', line 10 def initialize(adapter, = {}) super(adapter, ) @default_options = adapter.respond_to?(:default_options) ? adapter..dup : {} if .include?(:only) raise ArgumentError, 'Either :only or :except is allowed' if .include?(:except) methods = [.delete(:only)].compact.flatten elsif .include?(:except) methods = METHODS - [.delete(:except)].compact.flatten else methods = METHODS end methods.each do |method| if oldopts = @default_options[method] newopts = (@default_options[method] = oldopts.merge()) newopts[:prefix] = "#{oldopts[:prefix]}#{[:prefix]}" if oldopts[:prefix] || [:prefix] else @default_options[method] = end end end |
Instance Attribute Details
#default_options ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 |
# File 'lib/moneta/optionmerger.rb', line 6 def @default_options end |