Sha256: 20ea891e2457429fe545876607dbb4678ea0f1da38024e304812cbdd1864511b

Contents?: true

Size: 416 Bytes

Versions: 3

Compression:

Stored size: 416 Bytes

Contents

module Abilities
  module ActionController
    module Base
      extend ActiveSupport::Concern

      protected

      %w(can? cannot?).each do |name|
        define_method name do |action, subject|
          Abilities.send name, current_user, action, subject
        end
      end

      def authorize!(action, subject)
        raise Abilities::AccessDenied unless can? action, subject
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
abilities-0.1.0 lib/abilities/action_controller/base.rb
abilities-0.0.2 lib/abilities/action_controller/base.rb
abilities-0.0.1 lib/abilities/action_controller/base.rb