Class: StrongRuleset

Inherits:
Ruleset show all
Defined in:
lib/patterns/strong_ruleset.rb

Overview

StrongRuleset is not satisfied and not forceable if any of rules is not applicable

Instance Method Summary collapse

Methods inherited from Ruleset

add_rule, #applicable?, #each, #initialize, #not_satisfied?, rules

Constructor Details

This class inherits a constructor from Ruleset

Instance Method Details

#forceable?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/patterns/strong_ruleset.rb', line 14

def forceable?
  rules.all? do |rule|
    (rule.applicable? && rule.forceable?) || rule.satisfied?
  end
end

#not_applicable?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/patterns/strong_ruleset.rb', line 10

def not_applicable?
  rules.any?(&:not_applicable?)
end

#satisfied?(force: false) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
7
8
# File 'lib/patterns/strong_ruleset.rb', line 4

def satisfied?(force: false)
  rules.all? do |rule|
    (rule.applicable? && rule.satisfied?) || (force && rule.forceable?)
  end
end