Permalink
Browse files

Update readme.

  • Loading branch information...
1 parent f34e3d0 commit 7cfe62ac5b10b41470b453bfed7f16154a2c54e3 @cmeiklejohn committed Sep 3, 2011
Showing with 17 additions and 22 deletions.
  1. +17 −22 README.rdoc
View
@@ -14,50 +14,45 @@ place; for example:
=== Define profiles
-==== Implicit profiles
-
-Specify a dependency hash of profile name to objects. The watchmaker
-will either yield another watchmaker or a factory when resolving those
-dependencies.
+Specify car, garage and boat as a dependency for lots of things. Watchmaker
+will either use a watchmaker by that name to fulfill that dependency, or fall
+back to the factory if it doesn't exist.
Watchmaker.define :lots_of_things => [:car, :garage, :boat]
-==== Lambda-based profiles
-
-When called, will call the lambda.
+Specify a block with things to do do:
Watchmaker.define :two_garages do
2.times do
Factory.create :garage
end
end
-==== Factory-based profiles
-
-Create a garage using the garage factory.
+Specify a factory as a dependency:
Watchmaker.define :garage, :factories => [:garage] do
# Some other post-factory creation setup here.
end
-==== Watchmaker-based profiles
+Specify multiple factories as dependencies:
-Create a garage using the garage factory.
+ Watchmaker.define :garages, :factories => [:garage, :garage] do
+ # Some other post-factory creation setup here.
+ end
- Watchmaker.define :garage, :factories => [:garage]
+Pass those objects in to the block:
-Create a car using the car factory, and a garage using the garage
-watchmaker.
+ Watchmaker.define :car_and_driver, :factories => [:garage, :car] do |garage, car|
+ garage.cars << car
+ end
- Watchmaker.define :car, :factories => [:car], :watchmakers => [:garage]
+Sepcify another watchmaker as a dependency:
-==== Inject created objects into the lambda
+ Watchmaker.define :car, :watchmakers => [:garage]
-Inject the factory-created garage and car into the block.
+Specify a factory and a watchmaker as a dependency:
- Watchmaker.define :car_in_garage, :factories => [:garage, :car] do |garage, car|
- garage.cars << car
- end
+ Watchmaker.define :car, :factories => [:car], :watchmakers => [:garage]
=== Manufacture objects

0 comments on commit 7cfe62a

Please sign in to comment.