lib/active_configuration/setting_proxy.rb
# Replaces the underlying Hash or Array with a replacement. This handles
# reverting to defaults when nil is given as the value.
#
# Note: Athough Hashes given may contain keys other than :modifier and
# :value, all other keys will be stripped out and not saved.
#
# @raise [ArgumentError] if a Hash, Array or NilClass isn't given for a
#   multiple option.
# @raise [ArgumentError] if a Hash or NilClass isn't given for a non-multiple
#   option.
#
# @param [Hash] value_with_modifier the Hash or Array of Hashes containing
#   modifier and value pairs.
#
# @return [Hash, Array] the requested change.
Replaces the underlying Hash or Array with a replacement. This handles
reverting to defaults when nil is given as the value.

Athough Hashes given may contain keys other than :modifier and
:value, all other keys will be stripped out and not saved.
Replaces the underlying Hash or Array with a replacement . This handles reverting to defaults when nil is given as the value . Athough Hashes given may contain keys other than : modifier and : value all other keys will be stripped out and not saved .
def replace(value_with_modifier)
      if option.allow_multiple?
        if value_with_modifier.is_a?(Hash) or value_with_modifier.is_a?(Array) or value_with_modifier.is_a?(NilClass)
          value_with_modifier = [value_with_modifier].flatten.collect{|value_with_modifier| {:modifier => nil, :value => nil}.merge(value_with_modifier.nil? ? {} : value_with_modifier.slice(*[:modifier, :value]))}
          value_with_modifier.delete({:modifier => nil, :value => nil})
        else
          raise ArgumentError, "Array expected."
        end
      else
        if value_with_modifier.is_a?(Hash) or value_with_modifier.is_a?(NilClass)
          value_with_modifier = {:modifier => nil, :value => nil}.merge(value_with_modifier.nil? ? {:value => coerce(option.default_value)} : value_with_modifier.slice(*[:modifier, :value]))
        else
          raise ArgumentError, "Hash expected."
        end
      end
      return (@value = value_with_modifier)
    end
def replace ( value_with_modifier ) if option . allow_multiple? if value_with_modifier . is_a? ( Hash ) or value_with_modifier . is_a? ( Array ) or value_with_modifier . is_a? ( NilClass ) value_with_modifier = [ value_with_modifier ] . flatten . collect { | value_with_modifier | { :modifier => nil , :value => nil } . merge ( value_with_modifier . nil? ? { } : value_with_modifier . slice ( * [ :modifier , :value ] ) ) } value_with_modifier . delete ( { :modifier => nil , :value => nil } ) else raise ArgumentError , "Array expected." end else if value_with_modifier . is_a? ( Hash ) or value_with_modifier . is_a? ( NilClass ) value_with_modifier = { :modifier => nil , :value => nil } . merge ( value_with_modifier . nil? ? { :value => coerce ( option . default_value ) } : value_with_modifier . slice ( * [ :modifier , :value ] ) ) else raise ArgumentError , "Hash expected." end end return ( @value = value_with_modifier ) end
Replaces the underlying Hash or Array with a replacement.
Replaces the underlying Hash or Array with a replacement .
the requested change.
the requested change .
Hash, Array
[ArgumentError] if a Hash, Array or NilClass isn't given for a multiple option.
[ ArgumentError ] if a Hash Array or NilClass isn ' t given for a multiple option .
[ArgumentError] if a Hash or NilClass isn't given for a non-multiple option.
[ ArgumentError ] if a Hash or NilClass isn ' t given for a non - multiple option .
value_with_modifier
<not_specific>
<not_specific>
value_with_modifier the Hash or Array of Hashes containing modifier and value pairs.
value_with_modifier the Hash or Array of Hashes containing modifier and value pairs .