Module: Canql::Nodes::WithConditions
- Defined in:
- lib/canql/nodes/main.rb
Overview
Provides meta data for with conditions that return multiple instances of a condition type as an array
Instance Method Summary collapse
- #add_sub_clause(sub_clauses, element, key, condition) ⇒ Object
- #build_sub_clauses ⇒ Object
- #meta_data_item ⇒ Object
Instance Method Details
#add_sub_clause(sub_clauses, element, key, condition) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/canql/nodes/main.rb', line 60 def add_sub_clause(sub_clauses, element, key, condition) return sub_clauses unless element.respond_to?(condition) sub_clauses[key] ||= [] sub_clauses[key] << element.send(condition) end |
#build_sub_clauses ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/canql/nodes/main.rb', line 44 def build_sub_clauses sub_clauses = {} post.elements.each do |element| add_sub_clause(sub_clauses, element, :anomalies, :to_anomaly) add_sub_clause(sub_clauses, element, :genetic_tests, :to_genetic_test) add_sub_clause(sub_clauses, element, :test_results, :to_test_result) add_sub_clause( sub_clauses, element, :test_result_groups, :to_test_result_group ) add_sub_clause(sub_clauses, element, :test_acceptances, :to_test_acceptance) add_sub_clause(sub_clauses, element, :events, :to_events) end sub_clauses end |
#meta_data_item ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/canql/nodes/main.rb', line 30 def conditions = {} sub_clauses = build_sub_clauses %i[ anomalies genetic_tests test_results test_result_groups test_acceptances events ].each do |condition_key| if sub_clauses[condition_key].present? conditions[condition_key.to_s] = { Canql::ALL => sub_clauses[condition_key] } end end conditions end |