Sha256: ed5740762c5ef4cb63e1d823c31e8cd32aa1537b2a766a4764970996ddfaa7c2

Contents?: true

Size: 537 Bytes

Versions: 10

Compression:

Stored size: 537 Bytes

Contents

module AccessGranted
  module Rails
    module ControllerMethods
      def current_policy
        @current_policy ||= ::AccessPolicy.new(current_user)
      end

      def self.included(base)
        base.helper_method :can?, :cannot?, :current_policy if base.respond_to? :helper_method
      end

      def can?(*args)
        current_policy.can?(*args)
      end

      def cannot?(*args)
        current_policy.cannot?(*args)
      end

      def authorize!(*args)
        current_policy.authorize!(*args)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
access-granted-1.3.3 lib/access-granted/rails/controller_methods.rb
access-granted-1.3.1 lib/access-granted/rails/controller_methods.rb
access-granted-1.3.0 lib/access-granted/rails/controller_methods.rb
access-granted-1.2.0 lib/access-granted/rails/controller_methods.rb
access-granted-1.1.2 lib/access-granted/rails/controller_methods.rb
access-granted-1.1.1 lib/access-granted/rails/controller_methods.rb
access-granted-1.1.0 lib/access-granted/rails/controller_methods.rb
access-granted-1.0.4 lib/access-granted/rails/controller_methods.rb
access-granted-1.0.3 lib/access-granted/rails/controller_methods.rb
access-granted-1.0.2 lib/access-granted/rails/controller_methods.rb