Class: Github::ServiceHook::Payload

Inherits:
OpenStruct show all
Defined in:
lib/github.rb

Direct Known Subclasses

Request::Payload::Github

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#payloadObject (readonly)

Returns the value of attribute payload.



33
34
35
# File 'lib/github.rb', line 33

def payload
  @payload
end

Instance Method Details

#commitsObject



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_urlObject



55
56
57
# File 'lib/github.rb', line 55

def compare_url
  self['compare']
end

#last_commitObject



45
46
47
# File 'lib/github.rb', line 45

def last_commit
  commits.last
end

#repositoryObject



41
42
43
# File 'lib/github.rb', line 41

def repository
  @repository ||= Repository.new(super)
end