Class: Event

Inherits:
Object
  • Object
show all
Defined in:
app/models/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Event

Returns a new instance of Event.



4
5
6
7
8
# File 'app/models/event.rb', line 4

def initialize(data)
  @data = data
  @name = data[:name]
  @project = data[:project_id] ? Project.find(data[:project_id]) : nil
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



2
3
4
# File 'app/models/event.rb', line 2

def data
  @data
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'app/models/event.rb', line 2

def name
  @name
end

#projectObject

Returns the value of attribute project.



2
3
4
# File 'app/models/event.rb', line 2

def project
  @project
end

Instance Method Details

#as_jsonObject



20
21
22
# File 'app/models/event.rb', line 20

def as_json
  data
end

#executeObject



10
11
12
13
14
15
16
17
18
# File 'app/models/event.rb', line 10

def execute
  return nil unless project.enabled_pipelines

  project.enabled_pipelines.each do |pipeline_definition|
    if pipeline_definition.constantize.trigger_when?(self)
      PipelineRunnerJob.perform_later(nil, self.data, pipeline_definition)
    end
  end
end