Clone this wiki locally
Licenses can be used as Permit mixins, ie. Permit rules that are reused in multiple types of Permits.
Licenses have their own namespace folder
license inside the
app/permits folder. The default (scope less) licenses are placed directly in the
- /app - /permits - /license - blogging.rb - /admin - blogging.rb
Default :blogging License (scope less):
module License class Blogging < CanTango::License module Cache def calc_rules can [:create, :edit], Post end end module NoCache def calc_rules can :publish, Post if session[:publishing] == :on end end end end
In the Blogging example, the module
NoCache is used to determine the rules that apply for the
:no_cache execution mode.
The :editor License applicable for the Admin scope. Typically the scope is linked to the account (but doesn't have to be).
module License::Admin class Blogging < CanTango::License def calc_rules can :edit, Post end modes :all end end