提交 55bb615f 编写于 作者: N Nicholas Seckar

Update duplicated OrderedOptions code.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3664 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 647130d7
......@@ -569,10 +569,8 @@ 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
......@@ -580,18 +578,14 @@ def []=(key, value)
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
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册