summaryrefslogtreecommitdiff
path: root/lib/declarative_policy/rule.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/declarative_policy/rule.rb')
-rw-r--r--lib/declarative_policy/rule.rb24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/declarative_policy/rule.rb b/lib/declarative_policy/rule.rb
index f38f4f0a50f..dd3d13bc5a0 100644
--- a/lib/declarative_policy/rule.rb
+++ b/lib/declarative_policy/rule.rb
@@ -18,20 +18,20 @@ module DeclarativePolicy
# `context` is a policy - an instance of
# DeclarativePolicy::Base.
def pass?(context)
- raise 'abstract'
+ raise "abstract"
end
# same as #pass? except refuses to do any I/O,
# returning nil if the result is not yet cached.
# used for accurately scoring And/Or
def cached_pass?(context)
- raise 'abstract'
+ raise "abstract"
end
# abstractly, how long would it take to compute
# this rule? lower-scored rules are tried first.
def score(context)
- raise 'abstract'
+ raise "abstract"
end
# unwrap double negatives and nested and/or
@@ -52,9 +52,9 @@ module DeclarativePolicy
Not.make(self)
end
- alias_method :|, :or
- alias_method :&, :and
- alias_method :~@, :negate
+ alias | or
+ alias & and
+ alias ~ negate
def inspect
"#<Rule #{repr}>"
@@ -184,13 +184,13 @@ module DeclarativePolicy
end
def simplify
- simplified_rules = @rules.flat_map do |rule|
+ simplified_rules = @rules.flat_map { |rule|
simplified = rule.simplify
case simplified
when And then simplified.rules
else [simplified]
end
- end
+ }
And.new(simplified_rules)
end
@@ -222,7 +222,7 @@ module DeclarativePolicy
end
def repr
- "all?(#{rules.map(&:repr).join(', ')})"
+ "all?(#{rules.map(&:repr).join(", ")})"
end
end
@@ -241,13 +241,13 @@ module DeclarativePolicy
end
def simplify
- simplified_rules = @rules.flat_map do |rule|
+ simplified_rules = @rules.flat_map { |rule|
simplified = rule.simplify
case simplified
when Or then simplified.rules
else [simplified]
end
- end
+ }
Or.new(simplified_rules)
end
@@ -269,7 +269,7 @@ module DeclarativePolicy
end
def repr
- "any?(#{@rules.map(&:repr).join(', ')})"
+ "any?(#{@rules.map(&:repr).join(", ")})"
end
end