1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activesupport/lib/active_support/configurable.rb
Yehuda Katz a41c6c35ca Start adding configuration to ActionView instead of using constants.
By using config rather than hardcoded constants, we can evolve the
  configuration system over time (we'd just need to update the config
  method with more robust capabilities and all consumers would get
  the capabilities with no code changes)
2009-10-14 13:36:41 -07:00

35 lines
No EOL
783 B
Ruby

require "active_support/concern"
module ActiveSupport
module Configurable
extend ActiveSupport::Concern
module ClassMethods
def get_config
module_parts = name.split("::")
modules = [Object]
module_parts.each {|name| modules.push modules.last.const_get(name) }
modules.reverse_each do |mod|
return mod.const_get(:DEFAULT_CONFIG) if const_defined?(:DEFAULT_CONFIG)
end
{}
end
def config
self.config = get_config unless @config
@config
end
def config=(hash)
@config = ActiveSupport::OrderedOptions.new
hash.each do |key, value|
@config[key] = value
end
end
end
def config
self.class.config
end
end
end