Permalink
Browse files

Update duplicated OrderedOptions code.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3664 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 647130d commit 55bb615f108f766ff5afd6d36f2a013945332bc4 @seckar seckar committed Feb 26, 2006
Showing with 24 additions and 12 deletions.
  1. +24 −12 railties/lib/initializer.rb
@@ -569,29 +569,23 @@ def default_plugin_paths
# 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
else
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 @@ def find_pair(key)
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

0 comments on commit 55bb615

Please sign in to comment.