50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/bali/foundations/rule/rule_group.rb', line 50
def add_rule(rule)
raise Bali::DslError, "Rule must be of class Bali::Rule, got: #{rule.class.name}" unless rule.is_a?(Bali::Rule)
operation = rule.operation.to_sym
raise Bali::DslError, "Rule is defined twice for operation #{operation}" if self.cants[operation] && self.cans[operation]
if rule.is_discouragement?
self.cants[operation] = rule
self.cans.delete operation
else
self.cans[operation] = rule
self.cants.delete operation
end
end
|