aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-06-18 12:51:15 -0700
committerYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-06-23 14:49:03 -0700
commit99b8248f6e83b87fc7f09e43a11c68aebcb2712e (patch)
tree200619dd6f9b2efc3b970c3a5345aa3c7840296f
parent805369c8c84a15115e4f7a2fe9b3d4de07e2c7f2 (diff)
downloadrails-99b8248f6e83b87fc7f09e43a11c68aebcb2712e.tar.gz
rails-99b8248f6e83b87fc7f09e43a11c68aebcb2712e.tar.bz2
rails-99b8248f6e83b87fc7f09e43a11c68aebcb2712e.zip
Initial initializer impl
-rw-r--r--railties/test/new_initializer_test.rb17
1 files changed, 6 insertions, 11 deletions
diff --git a/railties/test/new_initializer_test.rb b/railties/test/new_initializer_test.rb
index 166e7e613f..ffa10060ce 100644
--- a/railties/test/new_initializer_test.rb
+++ b/railties/test/new_initializer_test.rb
@@ -11,20 +11,15 @@ module Rails
end
def add(name, options = {}, &block)
- if other = options[:before] || options[:after] and !@names[other]
- raise Error, "The #{other.inspect} initializer does not exist"
+ # If :before or :after is specified, set the index to the right spot
+ if other = options[:before] || options[:after]
+ raise Error, "The #{other.inspect} initializer does not exist" unless @names[other]
+ index = @initializers.index(@names[other])
+ index += 1 if options[:after]
end
Class.new(Initializer, &block).new.tap do |initializer|
- index = if options[:before]
- @initializers.index(@names[other])
- elsif options[:after]
- @initializers.index(@names[other]) + 1
- else
- -1
- end
-
- @initializers.insert(index, initializer)
+ @initializers.insert(index || -1, initializer)
@names[name] = initializer
end
end