class Enumpath::Operator::Union
Implements JSONPath union operator syntax. See {file:README.md#label-Union+operator} for syntax and examples
Constants
- CONSTRAINTS
- OPERATOR
- SPLIT_REGEX
Public Class Methods
detect?(operator)
click to toggle source
Whether the operator matches {Enumpath::Operator::Union::OPERATOR} and does not match {Enumpath::Operator::Union::CONSTRAINTS}
@param operator (see Enumpath::Operator::Base.detect?
) @return (see Enumpath::Operator::Base.detect?
)
# File lib/enumpath/operator/union.rb, line 23 def detect?(operator) operator.scan(',').any? && operator.scan(CONSTRAINTS).none? end
Public Instance Methods
apply(remaining_path, enum, resolved_path) { |[part] + remaining_path, enum, resolved_path| ... }
click to toggle source
Yields to the block once for every union member
@param (see Enumpath::Operator::Base#apply
) @yield (see Enumpath::Operator::Base#apply
) @yieldparam remaining_path [Array] the union member plus remaining_path @yieldparam enum [Enumerable] enum @yieldparam resolved_path [Array] resolved_path
# File lib/enumpath/operator/union.rb, line 35 def apply(remaining_path, enum, resolved_path) parts = operator.split(SPLIT_REGEX).map { |part| part.strip.gsub(/^['"]|['"]$/, '') } Enumpath.log('Applying union parts') { { parts: parts } } parts.each { |part| yield([part] + remaining_path, enum, resolved_path) } end