Skip to content

Instantly share code, notes, and snippets.

@lukaskonarovsky
Created March 22, 2009 20:23
Show Gist options
  • Save lukaskonarovsky/83286 to your computer and use it in GitHub Desktop.
Save lukaskonarovsky/83286 to your computer and use it in GitHub Desktop.
module Factory
def self.hash(name, attributes = {})
self.send("#{name}_hash").merge(attributes)
end
def self.build(name, attributes = {})
Kernel.const_get(name.to_s.capitalize).new(self.hash(name, attributes))
end
def self.create(name, attributes = {})
Kernel.const_get(name.to_s.capitalize).create(self.hash(name, attributes))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment