Sha256: b9ed1aa42577fe6e5d1e98f60184b7723dca5ad158c6e518c224bec6b8c757c2

Contents?: true

Size: 952 Bytes

Versions: 6

Compression:

Stored size: 952 Bytes

Contents

require 'active_support/concern'
require 'active_support/ordered_options'
require 'active_support/core_ext/kernel/singleton_class'
require 'active_support/core_ext/module/delegation'

module ActiveSupport
  module Configurable
    extend ActiveSupport::Concern

    module ClassMethods
      def config
        @_config ||= ActiveSupport::InheritableOptions.new(superclass.respond_to?(:config) ? superclass.config : {})
      end

      def configure
        yield config
      end

      def config_accessor(*names)
        names.each do |name|
          code, line = <<-RUBY, __LINE__ + 1
            def #{name}; config.#{name}; end
            def #{name}=(value); config.#{name} = value; end
          RUBY

          singleton_class.class_eval code, __FILE__, line
          class_eval code, __FILE__, line
        end
      end
    end

    def config
      @_config ||= ActiveSupport::InheritableOptions.new(self.class.config)
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
social_url_stats-0.0.1 vendor/ruby/1.9.1/gems/activesupport-3.0.0/lib/active_support/configurable.rb
activesupport-3.0.3 lib/active_support/configurable.rb
activesupport-3.0.2 lib/active_support/configurable.rb
activesupport-3.0.1 lib/active_support/configurable.rb
activesupport-3.0.0 lib/active_support/configurable.rb
activesupport-3.0.0.rc2 lib/active_support/configurable.rb