Class: Phenomenal::Relationship
- Inherits:
-
Object
- Object
- Phenomenal::Relationship
- Defined in:
- lib/phenomenal/relationship/relationship.rb
Overview
Define a first class relationship
Direct Known Subclasses
Instance Attribute Summary collapse
-
#feature ⇒ Object
Returns the value of attribute feature.
-
#manager ⇒ Object
Returns the value of attribute manager.
-
#source ⇒ Object
Returns the value of attribute source.
-
#target ⇒ Object
Returns the value of attribute target.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#activate_context(context) ⇒ Object
Must be redifined for each type of relation if necessary Called when a context is activated.
-
#activate_feature ⇒ Object
Must be redifined for each type of relation if necessary Called when a feature is activated.
-
#deactivate_context(context) ⇒ Object
Must be redifined for each type of relation if necessary Called when a context is deactivated.
-
#deactivate_feature ⇒ Object
Must be redifined for each type of relation if necessary Called when a feature is deactivated.
-
#initialize(source, target, feature) ⇒ Relationship
constructor
A new instance of Relationship.
- #refresh ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(source, target, feature) ⇒ Relationship
Returns a new instance of Relationship.
5 6 7 8 9 10 11 |
# File 'lib/phenomenal/relationship/relationship.rb', line 5 def initialize(source,target,feature) @source=source @target=target @manager=Phenomenal::Manager.instance @feature=feature refresh end |
Instance Attribute Details
#feature ⇒ Object
Returns the value of attribute feature.
3 4 5 |
# File 'lib/phenomenal/relationship/relationship.rb', line 3 def feature @feature end |
#manager ⇒ Object
Returns the value of attribute manager.
3 4 5 |
# File 'lib/phenomenal/relationship/relationship.rb', line 3 def manager @manager end |
#source ⇒ Object
Returns the value of attribute source.
3 4 5 |
# File 'lib/phenomenal/relationship/relationship.rb', line 3 def source @source end |
#target ⇒ Object
Returns the value of attribute target.
3 4 5 |
# File 'lib/phenomenal/relationship/relationship.rb', line 3 def target @target end |
Instance Method Details
#==(other) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/phenomenal/relationship/relationship.rb', line 13 def ==(other) self.class==other.class && self.source==other.source && self.target==other.target && self.feature==other.feature end |
#activate_context(context) ⇒ Object
Must be redifined for each type of relation if necessary Called when a context is activated
31 32 |
# File 'lib/phenomenal/relationship/relationship.rb', line 31 def activate_context(context) end |
#activate_feature ⇒ Object
Must be redifined for each type of relation if necessary Called when a feature is activated
43 44 |
# File 'lib/phenomenal/relationship/relationship.rb', line 43 def activate_feature end |
#deactivate_context(context) ⇒ Object
Must be redifined for each type of relation if necessary Called when a context is deactivated
37 38 |
# File 'lib/phenomenal/relationship/relationship.rb', line 37 def deactivate_context(context) end |
#deactivate_feature ⇒ Object
Must be redifined for each type of relation if necessary Called when a feature is deactivated
49 50 |
# File 'lib/phenomenal/relationship/relationship.rb', line 49 def deactivate_feature end |
#refresh ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/phenomenal/relationship/relationship.rb', line 20 def refresh s = manager.context_defined?(source) self.source=s if !s.nil? t = manager.context_defined?(target) self.target=t if !t.nil? end |
#to_s ⇒ Object
52 53 54 |
# File 'lib/phenomenal/relationship/relationship.rb', line 52 def to_s "#{self.class.name} between #{source.class.name}:#{source} and #{target.class.name}:#{target}" end |