Class: Phenomenal::Implication
- Inherits:
-
Relationship
- Object
- Relationship
- Phenomenal::Implication
- Defined in:
- lib/phenomenal/relationship/implication.rb
Overview
Define the behavior of the Implication relationship
Instance Attribute Summary collapse
-
#activation_counter ⇒ Object
Returns the value of attribute activation_counter.
Attributes inherited from Relationship
#feature, #manager, #source, #target
Instance Method Summary collapse
- #activate_context(context) ⇒ Object
- #activate_feature ⇒ Object
- #deactivate_context(context) ⇒ Object
- #deactivate_feature ⇒ Object
-
#initialize(source, target, feature) ⇒ Implication
constructor
A new instance of Implication.
Methods inherited from Relationship
Constructor Details
#initialize(source, target, feature) ⇒ Implication
Returns a new instance of Implication.
4 5 6 7 |
# File 'lib/phenomenal/relationship/implication.rb', line 4 def initialize(source,target,feature) super(source,target,feature) @activation_counter=0 end |
Instance Attribute Details
#activation_counter ⇒ Object
Returns the value of attribute activation_counter.
3 4 5 |
# File 'lib/phenomenal/relationship/implication.rb', line 3 def activation_counter @activation_counter end |
Instance Method Details
#activate_context(context) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/phenomenal/relationship/implication.rb', line 23 def activate_context(context) if source==context target.activate self.activation_counter+=1 end end |
#activate_feature ⇒ Object
9 10 11 12 13 14 |
# File 'lib/phenomenal/relationship/implication.rb', line 9 def activate_feature if source.active? target.activate self.activation_counter+=1 end end |
#deactivate_context(context) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/phenomenal/relationship/implication.rb', line 30 def deactivate_context(context) if source==context && activation_counter>0 target.deactivate self.activation_counter-=1 elsif activation_counter>0 source.deactivate self.activation_counter-=1 else # Nothing to do end end |
#deactivate_feature ⇒ Object
16 17 18 19 20 21 |
# File 'lib/phenomenal/relationship/implication.rb', line 16 def deactivate_feature if activation_counter>0 target.deactivate self.activation_counter-=1 end end |