lib/active_record/configuration.rb
# Configures the current ActiveRecord class to allow specific options.
# After being configured, a #settings method will be defined against
# all instances as well as a has_many :active_configuration_settings
# relationship for storing settings.
#
# Example configuration:
#
#   class Category < ActiveRecord::Base
#     configure do
#       option :sort do
#         default  'alphabetical'
#         restrict 'alphabetical', 'manual'
#       end
#
#       option :limit do
#         format 'fixnum'
#       end
#
#       option :price_filter do
#         format    'float'
#         modifiers 'eq', 'lt', 'gt', 'lte', 'gte'
#         multiple  true
#       end
#     end
#   end
#
# The #configure block can only contain #option blocks. Within each
# option block may be a number of methods such as:
#
# * default
#     A default value. Cannot be used in conjunction with multiple.
#
# * format -
#   A specific format, including: 'string', 'fixnum', 'float',
#   'boolean', 'email', 'url' or a /regular expression/. Defaults
#   to 'string'.
#
# * restrict -
#   An array of allowed values.
#
# * modifiers -
#   An array of allowed modifiers.
#
# * multiple -
#   Whether or not multiple Settings can be set against the single
#   option. Must be set to either true or false. Defaults to false.
#
#
# @param [Proc] block the configuration block that contains option blocks.
Configures the current ActiveRecord class to allow specific options.
After being configured, a #settings method will be defined against
all instances as well as a has_many :active_configuration_settings
relationship for storing settings.

Example configuration.



option :limit do
format 'fixnum'
end



The #configure block can only contain #option blocks. Within each
option block may be a number of methods such as.

default
A default value. Cannot be used in conjunction with multiple.



restrict
An array of allowed values.

modifiers
An array of allowed modifiers.

multiple
Whether or not multiple Settings can be set against the single
option. Must be set to either true or false. Defaults to false.
Configures the current ActiveRecord class to allow specific options . After being configured a #settings method will be defined against all instances as well as a has_many : active_configuration_settings relationship for storing settings . Example configuration . option : limit do format ' fixnum ' end The #configure block can only contain #option blocks . Within each option block may be a number of methods such as . default A default value . Cannot be used in conjunction with multiple . restrict An array of allowed values . modifiers An array of allowed modifiers . multiple Whether or not multiple Settings can be set against the single option . Must be set to either true or false . Defaults to false .
def configure(&block)
        class_eval <<-EOV
          # Includes the #settings method for reading and writing settings
          # against any instances of this class.
          include ActiveRecord::Configuration::InstanceMethods
          # Where the actual settings are stored against the instance.
          has_many :active_configuration_settings, :as => :configurable, :class_name => 'ActiveConfiguration::Setting'
          # Validates are run on settings along with other validations.
          validate :validate_settings
          # After being saved, outstanding setting modifications are saved.
          after_save :save_settings
          # Returns the configuration details of this class.
          def self.configuration
            @configuration ||= ActiveConfiguration::Base.new
          end
        EOV
        configuration.instance_eval(&block)
      end
def configure ( & block ) class_eval <<-EOV 

          # Includes the #settings method for reading and writing settings
          # against any instances of this class.
          include ActiveRecord::Configuration::InstanceMethods

          # Where the actual settings are stored against the instance.
          has_many :active_configuration_settings, :as => :configurable, :class_name => 'ActiveConfiguration::Setting'

          # Validates are run on settings along with other validations.
          validate :validate_settings

          # After being saved, outstanding setting modifications are saved.
          after_save :save_settings

          # Returns the configuration details of this class.
          def self.configuration
            @configuration ||= ActiveConfiguration::Base.new
          end
         EOV configuration . instance_eval ( & block ) end
Configures the current ActiveRecord class to allow specific options.
Configures the current ActiveRecord class to allow specific options .
# Evaluates the configuration block given to #configure. Each # option block is then evaluated and options are setup. For more # details, see ActiveConfiguration::Base.
block
<not_specific>
<not_specific>
block the configuration block that contains option blocks.
block the configuration block that contains option blocks .