Sha256: 91f83d9685c8ba85385045abde182748934adc2bf1a9f81afde9ff1cf4fd702f

Contents?: true

Size: 698 Bytes

Versions: 4

Compression:

Stored size: 698 Bytes

Contents

module CanTango
  module Api
    module Can
      module User
        include CanTango::Api::Ability::User
        # Example: generated from types of accounts! (see below)
        # def admin_can?(*args)
        #   current_user_ability(:admin).can?(*args)
        # end
        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
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cantango-api-0.1.3 lib/cantango/api/can/user.rb
cantango-api-0.1.2 lib/cantango/api/can/user.rb
cantango-api-0.1.1 lib/cantango/api/can/user.rb
cantango-api-0.1.0 lib/cantango/api/can/user.rb