Module: CanTango::Api::Can::User

Includes:
Ability::User
Defined in:
lib/cantango/api/can/user.rb

Class Method Summary collapse

Methods included from Ability::User

#current_user_ability, #user_ability

Methods included from Options

#ability_options, options_list, #options_list

Methods included from CanTango::Api::Common

#category, #create_ability

Class Method Details

.included(base) ⇒ Object

Example: generated from types of accounts! (see below) def admin_can?(*args)

current_user_ability(:admin).can?(*args)

end


10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/cantango/api/can/user.rb', line 10

def self.included(base)
  ::CanTango.config.users.registered.each do |user|
    base.class_eval %{
      def #{user}_can? *args
        current_user_ability(:#{user}).can?(*args)
      end

      def #{user}_cannot? *args
        current_user_ability(:#{user}).cannot?(*args)
      end
     }
  end
end