Permalink
Browse files

updated readme with info on factories

git-svn-id: svn+ssh://rubyforge.org/var/svn/atomicobjectrb/trunk/diy@120 7bd720c3-caf9-44c9-a48d-612f81e63739
  • Loading branch information...
1 parent 62ff1bf commit 51203503cdcd164054299e6f9d8c04169395567d swieton committed Nov 6, 2008
Showing with 20 additions and 4 deletions.
  1. +16 −0 README.txt
  2. +1 −1 test/factory_test.rb
  3. +2 −2 test/files/factory/factory.yml
  4. +1 −1 test/files/factory/{cat.rb → kitten.rb}
View
@@ -182,6 +182,22 @@ a per-object override (handled in the context YAML):
engine:
auto_require: false
+=== Factories
+
+It is possible to create factories automatically with DIY:
+
+ ---
+ car_dealer:
+ compose: car_factory
+
+ car_factory:
+ builds: car
+
+Then you can use the factory to easily build objects:
+
+ context = DIY::Context.from_file('context.yml')
+ context[:car_factory].create => <Car:0x81eb0>
+
=== Method Directive
This introduces the concept of first class methods. An object can now be constructed with a method object
View
@@ -27,7 +27,7 @@ def test_creates_factory
cat = cat_factory.create
- assert cat.is_a?(Cat)
+ assert cat.is_a?(Kitten)
assert_equal "meow", cat.meow
end
@@ -1,6 +1,6 @@
cat_factory:
- builds: cat
- library: cat
+ builds: kitten
+ library: kitten
dog_factory:
builds: dog
@@ -1,4 +1,4 @@
-class Cat
+class Kitten
def meow
"meow"
end

0 comments on commit 5120350

Please sign in to comment.