Created
August 4, 2008 13:25
-
-
Save jnicklas/3887 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
# If we load in the generator this way it will *always* be loaded | |
scope "merb-gen" do | |
Merb.add_generators File.join(File.dirname(__FILE), 'lib', 'generators', 'model') | |
end |
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
# normal stuff | |
require ... | |
# if we load in the generator this way, it will only be loaded if merb_datamapper is a dependency in the application | |
Merb.add_generators File.join(File.dirname(__FILE), 'generators', 'model') |
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 Merb::Generators | |
class DatamapperModelGenerator < ComponentGenerator | |
# do stuff here | |
template ... | |
end | |
# this thing should be invisible to the end user, since it will never be called | |
# directly | |
add_private :datamapper_model | |
end | |
# The model generator invokes the datamapper_model generator if | |
# the orm is set to :datamapper | |
Merb::Generators::ModelGenerator.invoke :datamapper_model, :orm => :datamapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment