Class: Commands::Init::TriggerModel

Inherits:
InitModel
  • Object
show all
Defined in:
lib/commands/init/trigger_model.rb

Overview

Each trigger model instance adds an array of triggers

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from InitModel

inheritable_attributes, inherited, #rank, run

Constructor Details

#initializeTriggerModel

Returns a new instance of TriggerModel.



16
17
18
# File 'lib/commands/init/trigger_model.rb', line 16

def initialize
  @triggers = self.class.triggers
end

Class Method Details

.abstractObject



12
13
14
# File 'lib/commands/init/trigger_model.rb', line 12

def self.abstract
  true
end

Instance Method Details

#execute(p4, models = nil, super_user = nil) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/commands/init/trigger_model.rb', line 20

def execute(p4, models=nil, super_user=nil)
  puts "triggers: #{@triggers}"

  triggers = p4.run('triggers', '-o')[0]['Triggers']
  puts "current triggers: #{triggers}"
  triggers = [] if triggers.nil?

  @triggers.each { |t| triggers << t }

  p4.input = {
      'Triggers' => triggers
  }
  p4.run('triggers', '-i')
end