Sha256: 9956cb13cffa161166578c83f313b93bf6b7eab237620a18f0de81cf6920b012

Contents?: true

Size: 573 Bytes

Versions: 3

Compression:

Stored size: 573 Bytes

Contents

#
# Authorization methods for CanCanCan
# https://github.com/CanCanCommunity/cancancan
#
module ActiveManageable
  module Authorization
    module CanCanCan
      extend ActiveSupport::Concern

      included do
        private

        def authorize(record:, action: nil)
          action ||= @current_method
          current_ability.authorize!(action, record)
        end

        def scoped_class
          model_class.accessible_by(current_ability)
        end

        def current_ability
          ::Ability.new(current_user)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_manageable-0.1.2 lib/active_manageable/authorization/cancancan.rb
active_manageable-0.1.1 lib/active_manageable/authorization/cancancan.rb
active_manageable-0.1.0 lib/active_manageable/authorization/cancancan.rb