Class: ActiveFacts::CQL::Compiler::CompilationContext
- Inherits:
-
Object
- Object
- ActiveFacts::CQL::Compiler::CompilationContext
- Defined in:
- lib/activefacts/cql/compiler/shared.rb
Instance Attribute Summary collapse
-
#allowed_forward_terms ⇒ Object
Returns the value of attribute allowed_forward_terms.
-
#bindings ⇒ Object
readonly
The Bindings in this declaration.
-
#left_contractable_clause ⇒ Object
Returns the value of attribute left_contractable_clause.
-
#left_contraction_allowed ⇒ Object
Returns the value of attribute left_contraction_allowed.
-
#left_contraction_conjunction ⇒ Object
Returns the value of attribute left_contraction_conjunction.
-
#player_by_role_name ⇒ Object
readonly
Returns the value of attribute player_by_role_name.
-
#vocabulary ⇒ Object
Returns the value of attribute vocabulary.
Instance Method Summary collapse
-
#bind(*clauses) ⇒ Object
Pass in an array of clauses or References for player identification and binding (creating the Bindings) It’s necessary to identify all players that define a role name first, so those names exist in the context for where they’re used.
-
#initialize(vocabulary) ⇒ CompilationContext
constructor
A new instance of CompilationContext.
-
#object_type(name) ⇒ Object
Look up this object_type by its name.
Constructor Details
#initialize(vocabulary) ⇒ CompilationContext
Returns a new instance of CompilationContext.
62 63 64 65 66 67 68 69 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 62 def initialize vocabulary @vocabulary = vocabulary @vocabulary_identifier = @vocabulary. @allowed_forward_terms = [] @bindings = {} @player_by_role_name = {} @left_contraction_allowed = false end |
Instance Attribute Details
#allowed_forward_terms ⇒ Object
Returns the value of attribute allowed_forward_terms.
55 56 57 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 55 def allowed_forward_terms @allowed_forward_terms end |
#bindings ⇒ Object (readonly)
The Bindings in this declaration
59 60 61 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 59 def bindings @bindings end |
#left_contractable_clause ⇒ Object
Returns the value of attribute left_contractable_clause.
57 58 59 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 57 def left_contractable_clause @left_contractable_clause end |
#left_contraction_allowed ⇒ Object
Returns the value of attribute left_contraction_allowed.
56 57 58 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 56 def left_contraction_allowed @left_contraction_allowed end |
#left_contraction_conjunction ⇒ Object
Returns the value of attribute left_contraction_conjunction.
58 59 60 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 58 def left_contraction_conjunction @left_contraction_conjunction end |
#player_by_role_name ⇒ Object (readonly)
Returns the value of attribute player_by_role_name.
60 61 62 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 60 def player_by_role_name @player_by_role_name end |
#vocabulary ⇒ Object
Returns the value of attribute vocabulary.
54 55 56 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 54 def vocabulary @vocabulary end |
Instance Method Details
#bind(*clauses) ⇒ Object
Pass in an array of clauses or References for player identification and binding (creating the Bindings) It’s necessary to identify all players that define a role name first, so those names exist in the context for where they’re used.
90 91 92 93 94 95 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 90 def bind *clauses cl = clauses.flatten cl.each { |clause| clause.identify_players_with_role_name(self) } cl.each { |clause| clause.identify_other_players(self) } cl.each { |clause| clause.bind(self) } end |
#object_type(name) ⇒ Object
Look up this object_type by its name
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 72 def object_type(name) constellation = @vocabulary.constellation player = constellation.ObjectType[[@vocabulary_identifier, name]] # Bind to an existing role which has a role name (that's why we bind those first) player ||= @player_by_role_name[name] if !player && @allowed_forward_terms.include?(name) @vocabulary.valid_entity_type_name(name) # No need for the result here, just no exceptional condition player = constellation.EntityType(@vocabulary, name, :concept => :new) end player end |