Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add setter.

Fixes #1.
  • Loading branch information...
commit 9c46d9f9e082f9b0b07a3b0747eec741d3abdd51 1 parent 455cb8e
@jnunemaker jnunemaker authored
Showing with 10 additions and 1 deletion.
  1. +4 −0 lib/morphine.rb
  2. +6 −1 spec/morphine_spec.rb
View
4 lib/morphine.rb
@@ -14,6 +14,10 @@ def register(name, &block)
define_method name do
dependencies[name] ||= instance_eval(&block)
end
+
+ define_method "#{name}=" do |service|
+ dependencies[name] = service
+ end
end
end
end
View
7 spec/morphine_spec.rb
@@ -26,5 +26,10 @@
Container().register(:service) { Struct.new(:client).new(client) }
container.service.client.should == container.client
end
+
+ it 'defines writer method to change service' do
+ container.client = 'new client'
+ container.client.should eq('new client')
+ end
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.