diff options
Diffstat (limited to 'activesupport/lib/active_support/ordered_options.rb')
-rw-r--r-- | activesupport/lib/active_support/ordered_options.rb | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/activesupport/lib/active_support/ordered_options.rb b/activesupport/lib/active_support/ordered_options.rb index 1e925145aa..48b5c92454 100644 --- a/activesupport/lib/active_support/ordered_options.rb +++ b/activesupport/lib/active_support/ordered_options.rb @@ -1,35 +1,37 @@ # OrderedHash is namespaced to prevent conflicts with other implementations -class ActiveSupport::OrderedHash < Array #:nodoc: - def []=(key, value) - if pair = find_pair(key) - pair.pop - pair << value - else - self << [key, value] +module ActiveSupport + class OrderedHash < Array #:nodoc: + def []=(key, value) + if pair = find_pair(key) + pair.pop + pair << value + else + self << [key, value] + end end - end - - def [](key) - pair = find_pair(key) - pair ? pair.last : nil - end - def keys - self.collect { |i| i.first } - end + def [](key) + pair = find_pair(key) + pair ? pair.last : nil + end - private - def find_pair(key) - self.each { |i| return i if i.first == key } - return false + def keys + self.collect { |i| i.first } end + + private + def find_pair(key) + self.each { |i| return i if i.first == key } + return false + end + end end class OrderedOptions < ActiveSupport::OrderedHash #:nodoc: def []=(key, value) super(key.to_sym, value) end - + def [](key) super(key.to_sym) end @@ -41,4 +43,4 @@ class OrderedOptions < ActiveSupport::OrderedHash #:nodoc: self[name] end end -end
\ No newline at end of file +end |