Created
March 22, 2009 20:23
-
-
Save lukaskonarovsky/83286 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
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