lib/repeatable/expression/base.rb in repeatable-0.5.0 vs lib/repeatable/expression/base.rb in repeatable-0.6.0
- old
+ new
@@ -22,9 +22,25 @@
NotImplementedError,
"Don't use Expression::Base directly. Subclasses must implement `#to_h`"
)
end
+ def union(other)
+ Union.new(self, other)
+ end
+ alias + union
+ alias | union
+
+ def intersection(other)
+ Intersection.new(self, other)
+ end
+ alias & intersection
+
+ def difference(other)
+ Difference.new(included: self, excluded: other)
+ end
+ alias - difference
+
private
def hash_key
self.class.name.split('::').last
.gsub(/(?<!\b)[A-Z]/) { "_#{Regexp.last_match[0]}" }