Module: Governor
- Defined in:
- lib/governor.rb,
lib/governor/rails.rb,
lib/governor/plugin.rb,
lib/governor/article.rb,
lib/governor/mapping.rb,
lib/governor/formatters.rb,
lib/governor/view_manager.rb,
lib/governor/plugin_manager.rb,
lib/governor/controllers/helpers.rb,
lib/governor/controllers/methods.rb,
lib/generators/governor/migrate_generator.rb,
lib/generators/governor/configure_generator.rb,
lib/generators/governor/create_articles_generator.rb
Defined Under Namespace
Modules: Article, Controllers, Formatters Classes: ConfigureGenerator, CreateArticlesGenerator, Engine, Mapping, MigrateGenerator, Plugin, PluginManager, ViewManager
Constant Summary collapse
- @@resources =
{}
Class Method Summary collapse
-
.authorize_if(&blk) ⇒ Object
Supply a set of rules that describe what the requirements are to perform a given Governor-related action on a given article.
-
.map(resource, options = {}) ⇒ Object
Maps a given resource name with a pair of options, to be supplied as arguments to the routes.
Class Method Details
.authorize_if(&blk) ⇒ Object
Supply a set of rules that describe what the requirements are to perform a given Governor-related action on a given article. Usually specified within the initializer, though evaluated in the scope of a Rails session.
Example (from the generated initialization file):
Governor. do |action, article|
case action.to_sym
when :new, :create
if respond_to?(:user_signed_in?)
user_signed_in?
else
raise "Set up Governor.authorize_if in #{File.(__FILE__)}"
end
when :edit, :update, :destroy
article. == instance_eval(&Governor.)
else
raise ArgumentError.new('action must be new, create, edit, update, or destroy')
end
end
95 96 97 |
# File 'lib/governor.rb', line 95 def self.(&blk) @@authorization_rules = blk end |
.map(resource, options = {}) ⇒ Object
Maps a given resource name with a pair of options, to be supplied as arguments to the routes. Usually called from within governate
.
70 71 72 |
# File 'lib/governor.rb', line 70 def self.map(resource, = {}) @@default_resource ||= self.resources[resource] = Governor::Mapping.new(resource, ) end |