diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG | 2 | ||||
-rw-r--r-- | railties/lib/initializer.rb | 41 |
2 files changed, 17 insertions, 26 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 75f4f15e06..0d1d84a61b 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Namespaced OrderedHash so the Rails implementation does not clash with any others. (fixes #4911) [Julian Tarkhanov] + * Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.] * Added script/process/inspector to do simple process status information on Rails dispatchers keeping pid files in tmp/pids [DHH] diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 96144091e8..16f213bc16 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -448,7 +448,7 @@ module Rails self.database_configuration_file = default_database_configuration_file for framework in default_frameworks - self.send("#{framework}=", OrderedOptions.new) + self.send("#{framework}=", Rails::OrderedOptions.new) end end @@ -576,9 +576,12 @@ module Rails end # Needs to be duplicated from Active Support since its needed before Active -# Support is available. -class OrderedHash < Array #:nodoc: - def []=(key, value) +# Support is available. Here both Options and Hash are namespaced to prevent +# conflicts with other implementations AND with the classes residing in ActiveSupport. +class Rails::OrderedOptions < Array #:nodoc: + def []=(key, value) + key = key.to_sym + if pair = find_pair(key) pair.pop pair << value @@ -586,30 +589,10 @@ class OrderedHash < Array #:nodoc: self << [key, value] end end - - def [](key) - pair = find_pair(key) - pair ? pair.last : nil - end - - 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 - -class OrderedOptions < OrderedHash #:nodoc: - def []=(key, value) - super(key.to_sym, value) - end - def [](key) - super(key.to_sym) + pair = find_pair(key.to_sym) + pair ? pair.last : nil end def method_missing(name, *args) @@ -619,4 +602,10 @@ class OrderedOptions < OrderedHash #:nodoc: self[name] end end + + private + def find_pair(key) + self.each { |i| return i if i.first == key } + return false + end end
\ No newline at end of file |