Sha256: f0ff0bc41a76230f41748a452979e36d60fe509d492a8f9305611295a9b29699

Contents?: true

Size: 628 Bytes

Versions: 6

Compression:

Stored size: 628 Bytes

Contents

require_dependency 'can_can_dry/helpers/can_can_dry_helper'

module CanCanDry
  module ControllerAuthorization
    include CanCanDry::Helpers::CanCanDryHelper

    def authorize_by_ability_mapping
      fail CanCan::AccessDenied, "Falhou ao tentar acessar #{path_hash}" unless
        can_by_path_hash?(path_hash)
    end

    private

    def path_hash
      params.select { |k, _v| %w(controller action id).include?(k) }
    end

    def ability_mapping
      @ability_mapping ||= begin
        require_dependency 'ability_mapping'
        require_dependency 'ability'
        ::AbilityMapping.new
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
can_can_dry-0.3.1 lib/can_can_dry/controller_authorization.rb
can_can_dry-0.3.0 lib/can_can_dry/controller_authorization.rb
can_can_dry-0.2.0 lib/can_can_dry/controller_authorization.rb
can_can_dry-0.1.0 lib/can_can_dry/controller_authorization.rb
can_can_dry-0.0.8 lib/can_can_dry/controller_authorization.rb
can_can_dry-0.0.7 lib/can_can_dry/controller_authorization.rb