Class: ActiveFacts::CQL::Compiler::InformalDefinition
- Inherits:
-
Definition
- Object
- Definition
- ActiveFacts::CQL::Compiler::InformalDefinition
show all
- Defined in:
- lib/activefacts/cql/compiler/informal.rb
Instance Attribute Summary
Attributes inherited from Definition
#constellation, #tree, #vocabulary
Instance Method Summary
collapse
Methods inherited from Definition
#all_bindings_in_clauses, #assert_literal_value, #build_all_steps, #build_step, #build_variables, #source, #to_s
Constructor Details
#initialize(kind, subject, phrases, text) ⇒ InformalDefinition
Returns a new instance of InformalDefinition.
5
6
7
8
9
10
|
# File 'lib/activefacts/cql/compiler/informal.rb', line 5
def initialize kind, subject, phrases, text
@kind = kind
@subject = subject
@phrases = phrases
@text = text
end
|
Instance Method Details
#apply_description(concept_type) ⇒ Object
22
23
24
25
26
27
|
# File 'lib/activefacts/cql/compiler/informal.rb', line 22
def apply_description concept_type
concept_type.concept.informal_description =
[ concept_type.concept.informal_description,
@text
].compact*".\n"
end
|
#compile ⇒ Object
12
13
14
15
16
17
18
19
20
|
# File 'lib/activefacts/cql/compiler/informal.rb', line 12
def compile
@context = CompilationContext.new(@vocabulary)
case @kind
when :each
compile_object_description
when :when
compile_fact_type_description
end
end
|
#compile_fact_type_description ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/activefacts/cql/compiler/informal.rb', line 36
def compile_fact_type_description
@clause = Compiler::Clause.new(@phrases) @context.bind [@clause] fact_type = @clause.match_existing_fact_type @context
apply_description fact_type if fact_type
false
end
|
#compile_object_description ⇒ Object
29
30
31
32
33
34
|
# File 'lib/activefacts/cql/compiler/informal.rb', line 29
def compile_object_description
object_type = @context.object_type(@subject)
raise "Cannot add informal description of undefined object #{@subject.inspect}" unless object_type
apply_description object_type
false
end
|