Class: Enumpath::Operator::Union
- Defined in:
 - lib/enumpath/operator/union.rb
 
Overview
Implements JSONPath union operator syntax. See README for syntax and examples
Constant Summary collapse
- OPERATOR =
 /,/- CONSTRAINTS =
 /^,|,$/- SPLIT_REGEX =
 /,/
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
- 
  
    
      .detect?(operator)  ⇒ true, false 
    
    
  
  
  
  
  
  
  
  
  
    
Whether the operator matches OPERATOR and does not match CONSTRAINTS.
 
Instance Method Summary collapse
- 
  
    
      #apply(remaining_path, enum, resolved_path) {|remaining_path, enum, resolved_path| ... } ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Yields to the block once for every union member.
 
Methods inherited from Base
Constructor Details
This class inherits a constructor from Enumpath::Operator::Base
Class Method Details
.detect?(operator) ⇒ true, false
Whether the operator matches OPERATOR and does not match CONSTRAINTS
      23 24 25  | 
    
      # File 'lib/enumpath/operator/union.rb', line 23 def detect?(operator) operator.scan(',').any? && operator.scan(CONSTRAINTS).none? end  | 
  
Instance Method Details
#apply(remaining_path, enum, resolved_path) {|remaining_path, enum, resolved_path| ... } ⇒ Object
Yields to the block once for every union member
      35 36 37 38 39  | 
    
      # 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  |