class DeclarativePolicy::Rule::Ability
A rule constructed from RuleDsl#can?
. Computes a different ability on the same subject.
Attributes
ability[R]
Public Class Methods
new(ability)
click to toggle source
# File lib/declarative_policy/rule.rb, line 150 def initialize(ability) @ability = ability end
Public Instance Methods
cached_pass?(context)
click to toggle source
# File lib/declarative_policy/rule.rb, line 163 def cached_pass?(context) runner = context.runner(@ability) return unless runner.cached? runner.pass? end
description(_context)
click to toggle source
# File lib/declarative_policy/rule.rb, line 170 def description(_context) "User can #{@ability.inspect}" end
pass?(context)
click to toggle source
# File lib/declarative_policy/rule.rb, line 159 def pass?(context) context.allowed?(@ability) end
repr()
click to toggle source
# File lib/declarative_policy/rule.rb, line 174 def repr "can?(#{@ability.inspect})" end
score(context)
click to toggle source
We ask the ability's runner for a score
# File lib/declarative_policy/rule.rb, line 155 def score(context) context.runner(@ability).score end