Class: Phenomenal::Relationship

Inherits:
Object
  • Object
show all
Defined in:
lib/phenomenal/relationship/relationship.rb

Overview

Define a first class relationship

Direct Known Subclasses

Implication, Requirement, Suggestion

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#featureObject

Returns the value of attribute feature.



3
4
5
# File 'lib/phenomenal/relationship/relationship.rb', line 3

def feature
  @feature
end

#managerObject

Returns the value of attribute manager.



3
4
5
# File 'lib/phenomenal/relationship/relationship.rb', line 3

def manager
  @manager
end

#sourceObject

Returns the value of attribute source.



3
4
5
# File 'lib/phenomenal/relationship/relationship.rb', line 3

def source
  @source
end

#targetObject

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_featureObject

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_featureObject

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

#refreshObject



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_sObject



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