Permalink
Browse files

Merge pull request #3 from JonRowe/allow_register_blocks_to_take_args

Allow parameters to be passed in on register.
  • Loading branch information...
2 parents a96d7bf + 9a8bf4c commit dee8875b8ad22b5eebd8ae6c0a1ab293332fc487 @bkeepers committed Sep 27, 2012
Showing with 7 additions and 2 deletions.
  1. +2 −2 lib/morphine.rb
  2. +5 −0 spec/morphine_spec.rb
View
@@ -11,8 +11,8 @@ def dependencies
module ClassMethods
def register(name, &block)
- define_method name do
- dependencies[name] ||= instance_eval(&block)
+ define_method name do |*args|
+ dependencies[name] ||= instance_exec(*args,&block)
end
define_method "#{name}=" do |service|
View
@@ -31,5 +31,10 @@
container.client = 'new client'
container.client.should eq('new client')
end
+
+ it 'passes arguments through to the block' do
+ Container().register(:pass_through) { |argument| argument }
+ container.pass_through(:a).should == :a
+ end
end
end

0 comments on commit dee8875

Please sign in to comment.