Module: CanTango::Api::Can::Account
- Includes:
- Ability::Account
- Defined in:
- lib/cantango/api/can/account.rb
Class Method Summary collapse
-
.included(base) ⇒ Object
Example: generated from types of accounts! (see below) def admin_account_can?(*args) current_account_ability(:admin).can?(*args) end.
Methods included from Ability::Account
#account_ability, #current_account_ability
Methods included from Options
#ability_options, options_list, #options_list
Methods included from CanTango::Api::Common
Class Method Details
.included(base) ⇒ Object
Example: generated from types of accounts! (see below) def admin_account_can?(*args)
current_account_ability(:admin).can?(*args)
end
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cantango/api/can/account.rb', line 9 def self.included(base) ::CanTango.config.accounts.registered.each do |account| # by default alias call to current_xxx_account to current_xxx (devise user method) unless already defined! unless base.methods.include? :"current_#{account}_account" define_method :"current_#{account}_account" do send :"current_#{account}" end end base.class_eval %{ def #{account}_account_can? *args current_account_ability(:#{account}).can?(*args) end def #{account}_account_cannot? *args current_account_ability(:#{account}).cannot?(*args) end } end end |