Skip to content

Instantly share code, notes, and snippets.

@jnicklas
Created August 4, 2008 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnicklas/3887 to your computer and use it in GitHub Desktop.
Save jnicklas/3887 to your computer and use it in GitHub Desktop.
# 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
# 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')
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