aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/configurable.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-11-17 22:47:23 +0000
committerPratik Naik <pratiknaik@gmail.com>2009-11-17 22:47:23 +0000
commit5446d5cb05b50a9a3f317ded774be438e0eff909 (patch)
tree6b0b87efe3e95783763208215a3159fb63217a6d /activesupport/lib/active_support/configurable.rb
parent9754debb9a72f9385950e5282f3642b995ab76d8 (diff)
parentf8877d4b2a2a6f68770b376f0b1391a6295f62f2 (diff)
downloadrails-5446d5cb05b50a9a3f317ded774be438e0eff909.tar.gz
rails-5446d5cb05b50a9a3f317ded774be438e0eff909.tar.bz2
rails-5446d5cb05b50a9a3f317ded774be438e0eff909.zip
Merge remote branch 'mainstream/master'
Conflicts: activesupport/lib/active_support/core_ext/hash/conversions.rb
Diffstat (limited to 'activesupport/lib/active_support/configurable.rb')
-rw-r--r--activesupport/lib/active_support/configurable.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/configurable.rb b/activesupport/lib/active_support/configurable.rb
new file mode 100644
index 0000000000..890f465ce1
--- /dev/null
+++ b/activesupport/lib/active_support/configurable.rb
@@ -0,0 +1,35 @@
+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 \ No newline at end of file