lib/active_configuration/option.rb
# Validates how the specified configuration options are used with one
# another. If an invalid configuration is detected, such as using both
# the #default method and setting #multiple to true, an exception of
# ActiveConfiguration::Error is raised.
#
# Note: This method is automatically called after each of the
# configuration methods are run.
Validates how the specified configuration options are used with one
another. If an invalid configuration is detected, such as using both
the #default method and setting #multiple to true, an exception of
ActiveConfiguration::Error is raised.

This method is automatically called after each of the
configuration methods are run.
Validates how the specified configuration options are used with one another . If an invalid configuration is detected such as using both the #default method and setting #multiple to true an exception of ActiveConfiguration :: Error is raised . This method is automatically called after each of the configuration methods are run .
def validate!
      if !@default_value.nil? and !@allowed_values.nil? and !@allowed_values.include?(@default_value)
        raise ActiveConfiguration::Error, "The default value '#{@default_value}' isn't present in the list of allowed values."
      end
      if ![TrueClass, FalseClass].include?(@allow_multiple.class)
        raise ActiveConfiguration::Error, 'The multiple option requires a boolean.'
      end
      if !@default_value.nil? and @allow_multiple
        raise ActiveConfiguration::Error, 'The default value cannot be set in combination with the multiple option.'
      end
      if !@allowed_format.nil? and !['string', 'fixnum', 'float', 'boolean', 'email', 'url'].include?(@allowed_format) and !@allowed_format.is_a?(Regexp)
        raise ActiveConfiguration::Error, "The format #{@allowed_format} is not supported."
      end
    end
def validate! if ! @default_value . nil? and ! @allowed_values . nil? and ! @allowed_values . include? ( @default_value ) raise ActiveConfiguration :: Error , "The default value '#{@default_value}' isn't present in the list of allowed values." end if ! [ TrueClass , FalseClass ] . include? ( @allow_multiple . class ) raise ActiveConfiguration :: Error , 'The multiple option requires a boolean.' end if ! @default_value . nil? and @allow_multiple raise ActiveConfiguration :: Error , 'The default value cannot be set in combination with the multiple option.' end if ! @allowed_format . nil? and ! [ 'string' , 'fixnum' , 'float' , 'boolean' , 'email' , 'url' ] . include? ( @allowed_format ) and ! @allowed_format . is_a? ( Regexp ) raise ActiveConfiguration :: Error , "The format #{@allowed_format} is not supported." end end
Validates how the specified configuration options are used with one
another.
Validates how the specified configuration options are used with one another .
# If both a default value and a list of allowed values are given, # the default value must appear in the list of allowed values. # If multiple is set, it must be set to either true or false. # If a default value is given, multiple must be false. # If a format is specified, it must be an allowed format. This # includes 'string', 'fixnum', 'float', 'boolean', 'email', 'url' # or a /regular exprssion.