diff options
Diffstat (limited to 'railties/lib/initializer.rb')
-rw-r--r-- | railties/lib/initializer.rb | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index ea54e568cd..6a2e765dbf 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -569,10 +569,8 @@ end # Needs to be duplicated from Active Support since its needed before Active # Support is available. -class OrderedOptions < Array # :nodoc: - def []=(key, value) - key = key.to_sym - +class OrderedHash < Array #:nodoc: + def []=(key, value) if pair = find_pair(key) pair.pop pair << value @@ -580,18 +578,14 @@ class OrderedOptions < Array # :nodoc: self << [key, value] end end - + def [](key) - pair = find_pair(key.to_sym) + pair = find_pair(key) pair ? pair.last : nil end - def method_missing(name, *args) - if name.to_s =~ /(.*)=$/ - self[$1.to_sym] = args.first - else - self[name] - end + def keys + self.collect { |i| i.first } end private @@ -600,3 +594,21 @@ class OrderedOptions < Array # :nodoc: return false end end + +class OrderedOptions < OrderedHash #:nodoc: + def []=(key, value) + super(key.to_sym, value) + end + + def [](key) + super(key.to_sym) + end + + def method_missing(name, *args) + if name.to_s =~ /(.*)=$/ + self[$1.to_sym] = args.first + else + self[name] + end + end +end
\ No newline at end of file |