aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-09-30 07:20:57 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-09-30 07:20:57 +0000
commit735f08aca0893b13ef9dd4369fb75a12fc63dd55 (patch)
tree617cbef4109dd017f80aa82557df48578cb45648 /railties
parentd994b41a05d650cffe441de04754cfbe8fc79c9a (diff)
downloadrails-735f08aca0893b13ef9dd4369fb75a12fc63dd55.tar.gz
rails-735f08aca0893b13ef9dd4369fb75a12fc63dd55.tar.bz2
rails-735f08aca0893b13ef9dd4369fb75a12fc63dd55.zip
Made the order of framework settings significant so config.action_controller.allow_concurrency can be specified before config.action_controller.fragment_cache_store, which relies on the value of the former
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2423 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/initializer.rb51
1 files changed, 35 insertions, 16 deletions
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index 495c4ee701..f942e97694 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -168,12 +168,12 @@ module Rails
self.database_configuration_file = default_database_configuration_file
for framework in default_frameworks
- self.send("#{framework}=", new_hash_with_method_access)
+ self.send("#{framework}=", OrderedOptions.new)
end
end
def database_configuration
- YAML::load(ERB.new((IO.read(database_configuration_file))).result)
+ YAML::load(ERB.new(IO.read(database_configuration_file)).result)
end
def environment_path
@@ -242,20 +242,6 @@ module Rails
def default_dependency_mechanism
:load
end
-
- def new_hash_with_method_access
- hash = Hash.new
-
- def hash.method_missing(name, *args)
- if has_key?(name)
- self[name]
- elsif name.to_s =~ /(.*)=$/
- self[$1.to_sym] = args.first
- end
- end
-
- hash
- end
def default_cache_classes
false
@@ -270,3 +256,36 @@ module Rails
end
end
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
+
+ if pair = find_pair(key)
+ pair.pop
+ pair << value
+ else
+ self << [key, value]
+ end
+ end
+
+ def [](key)
+ pair = find_pair(key.to_sym)
+ pair ? pair.last : nil
+ end
+
+ def method_missing(name, *args)
+ if name.to_s =~ /(.*)=$/
+ self[$1.to_sym] = args.first
+ else
+ 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