Class: ActiveFacts::CQL::Compiler::CompoundMatching
- Inherits:
-
Object
- Object
- ActiveFacts::CQL::Compiler::CompoundMatching
- Defined in:
- lib/activefacts/cql/compiler/transform_rule.rb
Instance Attribute Summary collapse
-
#targ_term_list ⇒ Object
Returns the value of attribute targ_term_list.
-
#transform_matchings ⇒ Object
Returns the value of attribute transform_matchings.
-
#transform_query ⇒ Object
Returns the value of attribute transform_query.
Instance Method Summary collapse
- #compile(context) ⇒ Object
-
#initialize(targ_term_list, transform_query, transform_matchings) ⇒ CompoundMatching
constructor
A new instance of CompoundMatching.
Constructor Details
#initialize(targ_term_list, transform_query, transform_matchings) ⇒ CompoundMatching
Returns a new instance of CompoundMatching.
45 46 47 48 49 |
# File 'lib/activefacts/cql/compiler/transform_rule.rb', line 45 def initialize targ_term_list, transform_query, transform_matchings @targ_term_list = targ_term_list @transform_query = transform_query @transform_matchings = transform_matchings end |
Instance Attribute Details
#targ_term_list ⇒ Object
Returns the value of attribute targ_term_list.
43 44 45 |
# File 'lib/activefacts/cql/compiler/transform_rule.rb', line 43 def targ_term_list @targ_term_list end |
#transform_matchings ⇒ Object
Returns the value of attribute transform_matchings.
43 44 45 |
# File 'lib/activefacts/cql/compiler/transform_rule.rb', line 43 def transform_matchings @transform_matchings end |
#transform_query ⇒ Object
Returns the value of attribute transform_query.
43 44 45 |
# File 'lib/activefacts/cql/compiler/transform_rule.rb', line 43 def transform_query @transform_query end |
Instance Method Details
#compile(context) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/activefacts/cql/compiler/transform_rule.rb', line 51 def compile(context) compound_rule = nil vocabulary_identifier = context.vocabulary. constellation = context.vocabulary.constellation source_ot = nil source_query = nil if @transform_query.is_a?(ActiveFacts::CQL::Compiler::Reference) if (source_ot = constellation.ObjectType[[vocabulary_identifier, @transform_query.term]]).nil? raise "Invalid source object '#{@transform_query.term}' for '#{@targ_term.term}' transformation" end elsif @transform_query.is_a?(Array) query = Query.new(nil, @transform_query.flatten) query.constellation = constellation query.vocabulary = context.vocabulary if (source_query = query.compile).nil? raise "Invalid source query for '#{@targ_term.term}' transformation" end end compound_rule = constellation.CompoundMatching( :new, :source_object_type => source_ot, :source_query => source_query ) ActiveFacts::CQL::Compiler.build_transform_target_refs(context, @targ_term_list, compound_rule) @transform_matchings.each do |tr| trule = tr.compile(context) trule.compound_matching = compound_rule end compound_rule end |