Class: Vert::Authorization::PolicyFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/vert/authorization/policy_finder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ PolicyFinder

Returns a new instance of PolicyFinder.



8
9
10
# File 'lib/vert/authorization/policy_finder.rb', line 8

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



6
7
8
# File 'lib/vert/authorization/policy_finder.rb', line 6

def object
  @object
end

Instance Method Details

#policyObject



12
13
14
# File 'lib/vert/authorization/policy_finder.rb', line 12

def policy
  find_policy || DynamicPolicy
end

#policy!Object



16
17
18
# File 'lib/vert/authorization/policy_finder.rb', line 16

def policy!
  policy || raise(Pundit::NotDefinedError, "Unable to find policy for #{object}")
end

#scopeObject



20
21
22
# File 'lib/vert/authorization/policy_finder.rb', line 20

def scope
  find_scope || DynamicPolicy::Scope
end

#scope!Object



24
25
26
# File 'lib/vert/authorization/policy_finder.rb', line 24

def scope!
  scope || raise(Pundit::NotDefinedError, "Unable to find scope for #{object}")
end