diff options
author | Nicholas Seckar <nseckar@gmail.com> | 2006-02-26 01:56:09 +0000 |
---|---|---|
committer | Nicholas Seckar <nseckar@gmail.com> | 2006-02-26 01:56:09 +0000 |
commit | 55bb615f108f766ff5afd6d36f2a013945332bc4 (patch) | |
tree | 255c155760695a01ee0a7eb4416f5ef2f079aec1 /railties | |
parent | 647130d7ff43c91c5be14e27a9bcd1ad4a61985e (diff) | |
download | rails-55bb615f108f766ff5afd6d36f2a013945332bc4.tar.gz rails-55bb615f108f766ff5afd6d36f2a013945332bc4.tar.bz2 rails-55bb615f108f766ff5afd6d36f2a013945332bc4.zip |
Update duplicated OrderedOptions code.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3664 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties')
-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 |