class Governor::Plugin
Attributes
Public Class Methods
# File lib/governor/plugin.rb, line 4 def initialize(name) @name = name @migrations = [] @resources = {} @partials = {} @mimes = [] end
Public Instance Methods
# File lib/governor/plugin.rb, line 12 def add_migration(path) @migrations << path end
# File lib/governor/plugin.rb, line 81 def register_controller_callback(&block) @controller_callback = block end
Evaluates the block in the scope of the model. This is the equivalent of creating a mixin, including it within your article class and implementing self.included
.
Example:
thinking_sphinx = Governor::Plugin.new('thinking_sphinx') thinking_sphinx.register_model_callback do |base| base.define_index do indexes title indexes description indexes post has created_at set_property :delta => true end end
# File lib/governor/plugin.rb, line 77 def register_model_callback(&block) @model_callback = block end
Specifies that this plugin will display a partial of the given type, at the given path. This path is relative to the views directory underneath your app; it’s expected that there will be a governor directory underneath views as well.
DOCUMENTME I need to indicate which types are supported.
Example:
comments.register_partial :after_article_whole, 'articles/comments'
# File lib/governor/plugin.rb, line 45 def register_partial(type, path) @partials[type.to_sym] = path end
Defines mime types that this plugin responds to. These mime types will be passed on to the controller.
Example:
plugin.responds_to :xml, :json
Specifies that this plugin can deliver a view for XML documents as well as JSON.
Any arguments that can be passed to respond_to
in the controller can be passed here:
plugin.responds_to :atom, :only => :index
This specifies that the :index action responds to :atom, but no others.
# File lib/governor/plugin.rb, line 101 def responds_to(*mimes) @mimes << mimes end
Adds routes for articles. These can add member or collection routes to articles, or even nested resources.
Example:
comments = Governor::Plugin.new('comments') comments.set_routes do resources :comments do member do put 'mark_spam', 'not_spam' end end end
# File lib/governor/plugin.rb, line 30 def set_routes(&block) @routes = block end