Sha256: 7a19e227a0bec3df1a44c229ba3bbc92287a19144677b1bac2b7a62b2dde4f7a

Contents?: true

Size: 496 Bytes

Versions: 3

Compression:

Stored size: 496 Bytes

Contents

module PapersPlease
  module Rails
    module ControllerMethods
      def self.included(base)
        base.helper_method :can?, :cannot?, :policy if base.respond_to? :helper_method
      end

      def policy
        @policy ||= ::PapersPlease::Policy.new(current_user)
      end

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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
papers_please-0.1.4 lib/papers_please/rails/controller_methods.rb
papers_please-0.1.3 lib/papers_please/rails/controller_methods.rb
papers_please-0.1.2 lib/papers_please/rails/controller_methods.rb