Sha256: 51c25e4325c3d68501af64474c495d0e3d44234092ab12a84cb2107fe2356424

Contents?: true

Size: 1.48 KB

Versions: 7

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true
require 'abilities/thecore_auth_commons'

class Ability
  include CanCan::Ability

  def initialize(user)
    # Define abilities for the passed in user here. For example:
    #
    #   user ||= User.new # guest user (not logged in)
    #   if user.admin?
    #     can :manage, :all
    #   else
    #     can :read, :all
    #   end
    #
    # The first argument to `can` is the action you are giving the user
    # permission to do.
    # If you pass :manage it will apply to every action. Other common actions
    # here are :read, :create, :update and :destroy.
    #
    # The second argument is the resource the user can perform the action on.
    # If you pass :all it will apply to every resource. Otherwise pass a Ruby
    # class of the resource.
    #
    # The third argument is an optional hash of conditions to further filter the
    # objects.
    # For example, here the user can only update published articles.
    #
    #   can :update, Article, :published => true
    #
    # See the wiki for details:
    # https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities

    # This will always be the first Ability, since the abilities are "last wins"
    self.merge Abilities::ThecoreAuthCommons.new user
    # Other Abilities
    Abilities.constants(false).each do |ability|
      unless ability.to_s == "ThecoreAuthCommons"
        const = Abilities.const_get(ability) 
        self.merge const.new(user) if const.is_a? Class
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
thecore_auth_commons-2.2.2 app/models/ability.rb
thecore_auth_commons-2.2.1 app/models/ability.rb
thecore_auth_commons-2.2.0 app/models/ability.rb
thecore_auth_commons-2.1.9 app/models/ability.rb
thecore_auth_commons-2.1.8 app/models/ability.rb
thecore_auth_commons-2.1.7 app/models/ability.rb
thecore_auth_commons-2.1.5 app/models/ability.rb