Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit dee8875b8ad22b5eebd8ae6c0a1ab293332fc487 2 parents a96d7bf + 9a8bf4c
Brandon Keepers authored
Showing with 7 additions and 2 deletions.
  1. +2 −2 lib/morphine.rb
  2. +5 −0 spec/morphine_spec.rb
4 lib/morphine.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|
5 spec/morphine_spec.rb
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
Please sign in to comment.
Something went wrong with that request. Please try again.