Skip to content

Instantly share code, notes, and snippets.

@nalanj
Created April 5, 2009 03:10
Show Gist options
  • Save nalanj/90356 to your computer and use it in GitHub Desktop.
Save nalanj/90356 to your computer and use it in GitHub Desktop.
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