Sha256: d6f5ff980ad7dd1d3b0d0e7235e2ffbfcc55622c416ffa37822504ac5a63aaa3

Contents?: true

Size: 568 Bytes

Versions: 13

Compression:

Stored size: 568 Bytes

Contents

require 'cancan'

module RailsOps::AuthorizationBackend
  class CanCanCan < Abstract
    EXCEPTION_CLASS = 'CanCan::AccessDenied'.freeze

    def initialize
      super

      unless defined?(CanCanCan)
        fail 'RailsOps is configured to use CanCanCan authorization' \
             "backend, but the Gem 'cancancan' does not appear to be installed."
      end
    end

    def authorize!(operation, *args)
      ability = operation.context.try(:ability) || fail(RailsOps::Exceptions::AuthorizationNotPerformable)
      ability.authorize!(*args)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rails_ops-1.5.8 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.5.7 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.5.6 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.5.5 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.5.4 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.5.0 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.4.8 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.4.7 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.4.6 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.4.5 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.4.4 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.4.3 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.4.2 lib/rails_ops/authorization_backend/can_can_can.rb