Class: GitHub::Commit

Inherits:
BaseModel show all
Defined in:
lib/github/models/commit.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository = nil, attrs = nil) ⇒ Commit

Returns a new instance of Commit.



5
6
7
8
# File 'lib/github/models/commit.rb', line 5

def initialize(repository = nil, attrs = nil)
  super(attrs)
  self.repository = repository
end

Class Method Details

.commits_from_hashes(h, repository) ⇒ Object



14
15
16
# File 'lib/github/models/commit.rb', line 14

def self.commits_from_hashes(h, repository)
  h.map { |commit_attrs| from_hash(commit_attrs, repository) }
end

.from_hash(h, repository) ⇒ Object



10
11
12
# File 'lib/github/models/commit.rb', line 10

def self.from_hash(h, repository)
  new(repository, h)
end

Instance Method Details

#authorObject



26
27
28
# File 'lib/github/models/commit.rb', line 26

def author
  User.from_hash(@table[:author]) if @table[:author]
end

#committerObject



22
23
24
# File 'lib/github/models/commit.rb', line 22

def committer
  User.from_hash(@table[:committer]) if @table[:committer]
end

#idObject



18
19
20
# File 'lib/github/models/commit.rb', line 18

def id
  @table[:id]
end

#parentsObject



30
31
32
33
34
# File 'lib/github/models/commit.rb', line 30

def parents
  @parents ||= @table[:parents].map do |parent_attrs|
    repository.commit(parent_attrs['id'])
  end
end