class DeclarativePolicy::Rule::Condition

A rule that checks a condition. This is the type of rule that results from a basic bareword in the rule dsl (see RuleDsl#method_missing).

Public Class Methods

new(name) click to toggle source
# File lib/declarative_policy/rule.rb, line 68
def initialize(name)
  @name = name
end

Public Instance Methods

cached_pass?(context) click to toggle source

returns nil unless it's already cached

# File lib/declarative_policy/rule.rb, line 85
def cached_pass?(context)
  condition = context.condition(@name)
  return unless condition.cached?

  condition.pass?
end
description(context) click to toggle source
# File lib/declarative_policy/rule.rb, line 92
def description(context)
  context.class.conditions[@name].description
end
pass?(context) click to toggle source

Let the ManifestCondition from the context decide whether we pass.

# File lib/declarative_policy/rule.rb, line 80
def pass?(context)
  context.condition(@name).pass?
end
repr() click to toggle source
# File lib/declarative_policy/rule.rb, line 96
def repr
  @name.to_s
end
score(context) click to toggle source

we delegate scoring to the condition. See ManifestCondition#score.

# File lib/declarative_policy/rule.rb, line 74
def score(context)
  context.condition(@name).score
end