Class: Github::ServiceHook::Payload
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Github::ServiceHook::Payload
- Defined in:
- lib/github.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
Instance Method Summary collapse
- #commits ⇒ Object
- #compare_url ⇒ Object
-
#initialize(payload) ⇒ Payload
constructor
A new instance of Payload.
- #last_commit ⇒ Object
- #repository ⇒ Object
Methods inherited from OpenStruct
Constructor Details
#initialize(payload) ⇒ Payload
Returns a new instance of Payload.
35 36 37 38 39 |
# File 'lib/github.rb', line 35 def initialize(payload) @payload = payload payload = ActiveSupport::JSON.decode(payload) if payload.is_a?(String) super(payload) end |
Instance Attribute Details
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
33 34 35 |
# File 'lib/github.rb', line 33 def payload @payload end |
Instance Method Details
#commits ⇒ Object
49 50 51 52 53 |
# File 'lib/github.rb', line 49 def commits @commits ||= Array(self['commits']).map do |commit| Commit.new(commit.merge('ref' => ref, 'compare_url' => compare_url), repository) end end |
#compare_url ⇒ Object
55 56 57 |
# File 'lib/github.rb', line 55 def compare_url self['compare'] end |
#last_commit ⇒ Object
45 46 47 |
# File 'lib/github.rb', line 45 def last_commit commits.last end |
#repository ⇒ Object
41 42 43 |
# File 'lib/github.rb', line 41 def repository @repository ||= Repository.new(super) end |