aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/ordered_options.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/ordered_options.rb')
-rw-r--r--activesupport/lib/active_support/ordered_options.rb8
1 files changed, 7 insertions, 1 deletions
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()