Class: ActiveFacts::CQL::Compiler::CompilationContext

Inherits:
Object
  • Object
show all
Defined in:
lib/activefacts/cql/compiler/shared.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vocabulary) ⇒ CompilationContext

Returns a new instance of CompilationContext.



45
46
47
48
49
50
51
# File 'lib/activefacts/cql/compiler/shared.rb', line 45

def initialize vocabulary
  @vocabulary = vocabulary
  @vocabulary_identifier = @vocabulary.identifying_role_values
  @allowed_forward_terms = []
  @bindings = {}
  @player_by_role_name = {}
end

Instance Attribute Details

#allowed_forward_termsObject

Returns the value of attribute allowed_forward_terms.



41
42
43
# File 'lib/activefacts/cql/compiler/shared.rb', line 41

def allowed_forward_terms
  @allowed_forward_terms
end

#bindingsObject (readonly)

The Bindings in this declaration



42
43
44
# File 'lib/activefacts/cql/compiler/shared.rb', line 42

def bindings
  @bindings
end

#player_by_role_nameObject (readonly)

Returns the value of attribute player_by_role_name.



43
44
45
# File 'lib/activefacts/cql/compiler/shared.rb', line 43

def player_by_role_name
  @player_by_role_name
end

Instance Method Details

#concept(name) ⇒ Object

Look up this concept by its name



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/activefacts/cql/compiler/shared.rb', line 54

def concept(name)
  constellation = @vocabulary.constellation
  player = constellation.Concept[[@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)
    player = constellation.EntityType(@vocabulary, name)
  end

  player
end