Sha256: ed886e09209640239c47b118dd6fcc72b34d9f7f09e3a31d6e8536f300151c3e

Contents?: true

Size: 931 Bytes

Versions: 8

Compression:

Stored size: 931 Bytes

Contents

# Define the behavior of the Suggestion relationship
class Phenomenal::Suggestion < Phenomenal::Relationship
  attr_accessor :activation_counter
  
  def initialize(source,target,feature)
    super(source,target,feature)
    @activation_counter=0
  end
  
  def activate_feature
    begin
      if source.active?
        target.activate
        self.activation_counter+=1
      end
    rescue
    end
  end
  
  def deactivate_feature
    begin
      if activation_counter>0
        target.deactivate
        self.activation_counter-=1
      end
    rescue
    end
  end
  
  def activate_context(context)
    begin
      if source==context
        target.activate
        self.activation_counter+=1
      end
    rescue
    end
  end
  
  def deactivate_context(context)
    begin
      if source==context && activation_counter>0
        target.deactivate
        self.activation_counter-=1
      end
    rescue
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
phenomenal-1.2.4 lib/phenomenal/relationship/suggestion.rb
phenomenal-1.2.3 lib/phenomenal/relationship/suggestion.rb
phenomenal-1.2.2 lib/phenomenal/relationship/suggestion.rb
phenomenal-1.2.1 lib/phenomenal/relationship/suggestion.rb
phenomenal-1.1.1 lib/phenomenal/relationships/suggestion.rb
phenomenal-1.1.0 lib/phenomenal/relationships/suggestion.rb
phenomenal-1.0.1 lib/phenomenal/relationships/suggestion.rb
phenomenal-1.0.0 lib/phenomenal/relationships/suggestion.rb