module Pundit

@api public

Constants

SUFFIX
VERSION

Public Class Methods

authorize(user, record, query, policy_class: nil, cache: nil) click to toggle source

@see [Pundit::Context#authorize]

# File lib/pundit.rb, line 74
def authorize(user, record, query, policy_class: nil, cache: nil)
  context = if cache
    Context.new(user: user, policy_cache: cache)
  else
    Context.new(user: user)
  end

  context.authorize(record, query: query, policy_class: policy_class)
end
included(base) click to toggle source
# File lib/pundit.rb, line 63
  def self.included(base)
    location = caller_locations(1, 1).first
    warn <<~WARNING
      'include Pundit' is deprecated. Please use 'include Pundit::Authorization' instead.
       (called from #{location.label} at #{location.path}:#{location.lineno})
    WARNING
    base.include Authorization
  end
policy(user, *args, **kwargs, &block) click to toggle source

@see [Pundit::Context#policy]

# File lib/pundit.rb, line 95
def policy(user, *args, **kwargs, &block)
  Context.new(user: user).policy(*args, **kwargs, &block)
end
policy!(user, *args, **kwargs, &block) click to toggle source

@see [Pundit::Context#policy!]

# File lib/pundit.rb, line 100
def policy!(user, *args, **kwargs, &block)
  Context.new(user: user).policy!(*args, **kwargs, &block)
end
policy_scope(user, *args, **kwargs, &block) click to toggle source

@see [Pundit::Context#policy_scope]

# File lib/pundit.rb, line 85
def policy_scope(user, *args, **kwargs, &block)
  Context.new(user: user).policy_scope(*args, **kwargs, &block)
end
policy_scope!(user, *args, **kwargs, &block) click to toggle source

@see [Pundit::Context#policy_scope!]

# File lib/pundit.rb, line 90
def policy_scope!(user, *args, **kwargs, &block)
  Context.new(user: user).policy_scope!(*args, **kwargs, &block)
end