Sha256: 4cb5023ff1539ce5f16c8553f85b67d0a3339280ad2ed63297fc34b97270d417

Contents?: true

Size: 554 Bytes

Versions: 18

Compression:

Stored size: 554 Bytes

Contents

require 'cancan'

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

    def initialize
      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

18 entries across 18 versions & 1 rubygems

Version Path
rails_ops-1.4.1 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.4.0 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.3.0 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.2.3 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.2.2 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.2.1 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.2.0 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.1.31 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.1.30 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.1.29 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.1.28 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.1.27 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.1.26 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.1.25 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.1.24 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.1.23 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.1.22 lib/rails_ops/authorization_backend/can_can_can.rb
rails_ops-1.1.21 lib/rails_ops/authorization_backend/can_can_can.rb