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.
49 50 51 52 53 54 55 56 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 49 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.
42 43 44 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 42 def allowed_forward_terms @allowed_forward_terms end |
#bindings ⇒ Object (readonly)
The Bindings in this declaration
46 47 48 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 46 def bindings @bindings end |
#left_contractable_clause ⇒ Object
Returns the value of attribute left_contractable_clause.
44 45 46 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 44 def left_contractable_clause @left_contractable_clause end |
#left_contraction_allowed ⇒ Object
Returns the value of attribute left_contraction_allowed.
43 44 45 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 43 def left_contraction_allowed @left_contraction_allowed end |
#left_contraction_conjunction ⇒ Object
Returns the value of attribute left_contraction_conjunction.
45 46 47 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 45 def left_contraction_conjunction @left_contraction_conjunction end |
#player_by_role_name ⇒ Object (readonly)
Returns the value of attribute player_by_role_name.
47 48 49 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 47 def player_by_role_name @player_by_role_name end |
#vocabulary ⇒ Object
Returns the value of attribute vocabulary.
41 42 43 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 41 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.
77 78 79 80 81 82 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 77 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
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 59 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 |