Class: ActiveFacts::CQL::Compiler::Binding
- Inherits:
-
Object
- Object
- ActiveFacts::CQL::Compiler::Binding
- 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 ⇒ Object
When binding fact instances, the instance goes here.
-
#player ⇒ Object
readonly
The ObjectType (object type).
-
#rebound_to ⇒ Object
Loose binding may set this to another binding.
-
#refs ⇒ Object
readonly
an array of the References.
-
#role_name ⇒ Object
readonly
Returns the value of attribute role_name.
-
#variable ⇒ Object
Returns the value of attribute variable.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #add_ref(ref) ⇒ Object
- #delete_ref(ref) ⇒ Object
-
#initialize(player, role_name = nil) ⇒ Binding
constructor
A new instance of Binding.
- #inspect ⇒ Object
- #key ⇒ Object
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
#instance ⇒ Object
When binding fact instances, the instance goes here
19 20 21 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 19 def instance @instance end |
#player ⇒ Object (readonly)
The ObjectType (object type)
14 15 16 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 14 def player @player end |
#rebound_to ⇒ Object
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 |
#refs ⇒ Object (readonly)
an array of the References
15 16 17 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 15 def refs @refs end |
#role_name ⇒ Object (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 |
#variable ⇒ Object
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 |
#add_ref(ref) ⇒ Object
43 44 45 46 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 43 def add_ref ref @refs << ref ref end |
#delete_ref(ref) ⇒ Object
48 49 50 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 48 def delete_ref ref @refs.delete ref end |
#inspect ⇒ Object
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 |
#key ⇒ Object
31 32 33 |
# File 'lib/activefacts/cql/compiler/shared.rb', line 31 def key "#{@player.name}#{@role_name && " (as #{@role_name})"}" end |