Class: Travis::Notifications::Worker::Payload

Inherits:
Object
  • Object
show all
Defined in:
lib/travis/notifications/worker/payload.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job, extra = {}) ⇒ Payload

Returns a new instance of Payload.



7
8
9
# File 'lib/travis/notifications/worker/payload.rb', line 7

def initialize(job, extra = {})
  @job, @extra = job, extra
end

Instance Attribute Details

#extraObject (readonly)

Returns the value of attribute extra.



5
6
7
# File 'lib/travis/notifications/worker/payload.rb', line 5

def extra
  @extra
end

#jobObject (readonly)

Returns the value of attribute job.



5
6
7
# File 'lib/travis/notifications/worker/payload.rb', line 5

def job
  @job
end

Instance Method Details

#base_dirObject



27
28
29
# File 'lib/travis/notifications/worker/payload.rb', line 27

def base_dir
  File.expand_path('../views', __FILE__)
end

#dataObject



19
20
21
# File 'lib/travis/notifications/worker/payload.rb', line 19

def data
  { :job => job, :repository => job.repository }
end

#render(format) ⇒ Object



15
16
17
# File 'lib/travis/notifications/worker/payload.rb', line 15

def render(format)
  Travis::Renderer.send(format, data, :type => 'worker', :template => template, :base_dir => base_dir).deep_merge(extra)
end

#templateObject



23
24
25
# File 'lib/travis/notifications/worker/payload.rb', line 23

def template
  job.class.name.underscore
end

#to_hashObject



11
12
13
# File 'lib/travis/notifications/worker/payload.rb', line 11

def to_hash
  render(:hash)
end