Class: ActiveFacts::CQL::Compiler::Binding

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

Overview

In a declaration, a Binding has one or more Reference’s. A Binding is for a single ObjectType, normally related to just one Role, and the references (References) to it will normally be the object_type name with the same adjectives (modulo loose binding), or a role name or subscript reference.

In some situations a Binding will have some References with the same adjectives, and one or more References with no adjectives - this is called “loose binding”.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(player, role_name = nil) ⇒ Binding

Returns a new instance of Binding.



21
22
23
24
25
# File 'lib/activefacts/cql/compiler/shared.rb', line 21

def initialize player, role_name = nil
  @player = player
  @role_name = role_name
  @refs = []
end

Instance Attribute Details

#instanceObject

When binding fact instances, the instance goes here



19
20
21
# File 'lib/activefacts/cql/compiler/shared.rb', line 19

def instance
  @instance
end

#playerObject (readonly)

The ObjectType (object type)



14
15
16
# File 'lib/activefacts/cql/compiler/shared.rb', line 14

def player
  @player
end

#rebound_toObject

Loose binding may set this to another binding



17
18
19
# File 'lib/activefacts/cql/compiler/shared.rb', line 17

def rebound_to
  @rebound_to
end

#refsObject (readonly)

an array of the References



15
16
17
# File 'lib/activefacts/cql/compiler/shared.rb', line 15

def refs
  @refs
end

#role_nameObject (readonly)

Returns the value of attribute role_name.



16
17
18
# File 'lib/activefacts/cql/compiler/shared.rb', line 16

def role_name
  @role_name
end

#variableObject

Returns the value of attribute variable.



18
19
20
# File 'lib/activefacts/cql/compiler/shared.rb', line 18

def variable
  @variable
end

Instance Method Details

#<=>(other) ⇒ Object



35
36
37
# File 'lib/activefacts/cql/compiler/shared.rb', line 35

def <=>(other)
  key <=> other.key
end

#inspectObject



27
28
29
# File 'lib/activefacts/cql/compiler/shared.rb', line 27

def inspect
  "#{@player.name}#{@role_name and @role_name.is_a?(Integer) ? " (#{@role_name})" : " (as #{@role_name})"}"
end

#keyObject



31
32
33
# File 'lib/activefacts/cql/compiler/shared.rb', line 31

def key
  "#{@player.name}#{@role_name && " (as #{@role_name})"}"
end