Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Made the order of framework settings significant so config.action_con…
…troller.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
  • Loading branch information
dhh committed Sep 30, 2005
1 parent d994b41 commit 735f08a
Showing 1 changed file with 35 additions and 16 deletions.
51 changes: 35 additions & 16 deletions railties/lib/initializer.rb
Expand Up @@ -168,12 +168,12 @@ def initialize
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
Expand Down Expand Up @@ -242,20 +242,6 @@ def default_controller_paths
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
Expand All @@ -270,3 +256,36 @@ def default_whiny_nils
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

0 comments on commit 735f08a

Please sign in to comment.