lib/hx/path.rb in hx-0.10.0 vs lib/hx/path.rb in hx-0.11.0

- old
+ new

@@ -28,15 +28,15 @@ def accept_path?(path) raise NotImplementedError, "#{self.class}#accept_path? not implemented" end def |(other) - Disjunction.new(self, other) + Disjunction.build(self, other) end def &(other) - Conjunction.new(self, other) + Conjunction.build(self, other) end def ~() Negation.new(self) end @@ -90,27 +90,32 @@ end class Conjunction include Connective - def self.new(*selectors) + def self.build(*selectors) if selectors.any? { |s| All === s } selectors.reject! { |s| All === s } case selectors.size when 0; return ALL when 1; return selectors.first end end - super(*selectors) + new(*selectors) end def accept_path?(path) @selectors.all? { |s| s.accept_path? path } end end class Disjunction include Connective + + def self.build(*selectors) + return ALL if selectors.any? { |s| All === s } + new(*selectors) + end def accept_path?(path) @selectors.any? { |s| s.accept_path? path } end end