aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/configurable.rb2
-rw-r--r--activesupport/lib/active_support/ordered_options.rb8
2 files changed, 8 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/configurable.rb b/activesupport/lib/active_support/configurable.rb
index 3d91560833..1914f10669 100644
--- a/activesupport/lib/active_support/configurable.rb
+++ b/activesupport/lib/active_support/configurable.rb
@@ -18,7 +18,7 @@ module ActiveSupport
def self.crystalize!(keys)
keys.each do |key|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
- def #{key}; self[#{key.inspect}]; end
+ def #{key}; _get(#{key.inspect}); end
RUBY
end
end
diff --git a/activesupport/lib/active_support/ordered_options.rb b/activesupport/lib/active_support/ordered_options.rb
index 99c6c5a0c0..124e1a74f8 100644
--- a/activesupport/lib/active_support/ordered_options.rb
+++ b/activesupport/lib/active_support/ordered_options.rb
@@ -18,6 +18,9 @@ require 'active_support/ordered_hash'
#
module ActiveSupport #:nodoc:
class OrderedOptions < OrderedHash
+ alias_method :_get, :[] # preserve the original #[] method
+ protected :_get # make it protected
+
def []=(key, value)
super(key.to_sym, value)
end
@@ -37,7 +40,10 @@ module ActiveSupport #:nodoc:
class InheritableOptions < OrderedOptions
def initialize(parent = nil)
- if parent
+ if parent.kind_of?(OrderedOptions)
+ # use the faster _get when dealing with OrderedOptions
+ super() { |h,k| parent._get(k) }
+ elsif parent
super() { |h,k| parent[k] }
else
super()