Created
April 5, 2009 03:10
-
-
Save nalanj/90356 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I'm thinking that the syntax for Industrial Revolution will be something like this: | |
Defining a Factory | |
================== | |
Factory.for Cat do | |
defaults do | |
cat = Cat.new | |
cat.name = "Mr. Whiskers" | |
cat.color = "Yellow" | |
cat.size = "Gigantic" | |
end | |
assemble_as(:russion_gray) do |cat| | |
cat.name = "Boris" | |
cat.color = "Gray" | |
cat.size = "Medium" | |
end | |
end | |
Then you would actually use the factory something like | |
====================================================== | |
# Just grab a cat based on the defaults | |
cat_named_frankie = Factory(Cat, :name => "Frankie") | |
# Grab a russion gray named Vladomir | |
vlad_the_russion_gray = Factory(Cat, :russian_gray, :name => "Vladomir") | |
Just some thoughts, but I'm wanting a good, reusable factory library that isn't bound to Rails or any other | |
libraries. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment