Class: Phenomenal::Suggestion

Inherits:
Relationship show all
Defined in:
lib/phenomenal/relationship/suggestion.rb

Overview

Define the behavior of the Suggestion relationship

Instance Attribute Summary collapse

Attributes inherited from Relationship

#feature, #manager, #source, #target

Instance Method Summary collapse

Methods inherited from Relationship

#==, #refresh, #to_s

Constructor Details

#initialize(source, target, feature) ⇒ Suggestion

Returns a new instance of Suggestion.



5
6
7
8
# File 'lib/phenomenal/relationship/suggestion.rb', line 5

def initialize(source,target,feature)
  super(source,target,feature)
  @activation_counter=0
end

Instance Attribute Details

#activation_counterObject

Returns the value of attribute activation_counter.



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

def activation_counter
  @activation_counter
end

Instance Method Details

#activate_context(context) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/phenomenal/relationship/suggestion.rb', line 30

def activate_context(context)
  begin
    if source==context
      target.activate
      self.activation_counter+=1
    end
  rescue
  end
end

#activate_featureObject



10
11
12
13
14
15
16
17
18
# File 'lib/phenomenal/relationship/suggestion.rb', line 10

def activate_feature
  begin
    if source.active?
      target.activate
      self.activation_counter+=1
    end
  rescue
  end
end

#deactivate_context(context) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/phenomenal/relationship/suggestion.rb', line 40

def deactivate_context(context)
  begin
    if source==context && activation_counter>0
      target.deactivate
      self.activation_counter-=1
    end
  rescue
  end
end

#deactivate_featureObject



20
21
22
23
24
25
26
27
28
# File 'lib/phenomenal/relationship/suggestion.rb', line 20

def deactivate_feature
  begin
    if activation_counter>0
      target.deactivate
      self.activation_counter-=1
    end
  rescue
  end
end