Class: Travis::Notifications::Pusher::Payload

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event, object, extra = {}) ⇒ Payload

Returns a new instance of Payload.



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

def initialize(event, object, extra = {})
  @event, @object, @extra = event, object, extra
end

Instance Attribute Details

#eventObject (readonly)

Returns the value of attribute event.



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

def event
  @event
end

#extraObject (readonly)

Returns the value of attribute extra.



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

def extra
  @extra
end

#objectObject (readonly)

Returns the value of attribute object.



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

def object
  @object
end

Instance Method Details

#base_dirObject



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

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

#dataObject



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

def data
  { :build => object, :repository => object.repository }
end

#render(format) ⇒ Object



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

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

#templateObject



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

def template
  event.to_s.split(':').join('/')
end

#to_hashObject



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

def to_hash
  render(:hash)
end