Class: Ballantine::Commit
- Inherits:
-
Object
- Object
- Ballantine::Commit
- Defined in:
- lib/ballantine/commit.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
associations.
-
#hash ⇒ Object
readonly
attributes.
-
#long_hash ⇒ Object
readonly
attributes.
-
#repo ⇒ Object
readonly
associations.
-
#subject ⇒ Object
readonly
attributes.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash:, repo:) ⇒ Commit
constructor
A new instance of Commit.
- #slack_message ⇒ String
- #update(**kwargs) ⇒ Commit
- #url ⇒ Object
Constructor Details
#initialize(hash:, repo:) ⇒ Commit
Returns a new instance of Commit.
27 28 29 30 |
# File 'lib/ballantine/commit.rb', line 27 def initialize(hash:, repo:) @hash = hash[...7] @repo = repo end |
Instance Attribute Details
#author ⇒ Object (readonly)
associations
6 7 8 |
# File 'lib/ballantine/commit.rb', line 6 def @author end |
#hash ⇒ Object (readonly)
attributes
5 6 7 |
# File 'lib/ballantine/commit.rb', line 5 def hash @hash end |
#long_hash ⇒ Object (readonly)
attributes
5 6 7 |
# File 'lib/ballantine/commit.rb', line 5 def long_hash @long_hash end |
#repo ⇒ Object (readonly)
associations
6 7 8 |
# File 'lib/ballantine/commit.rb', line 6 def repo @repo end |
#subject ⇒ Object (readonly)
attributes
5 6 7 |
# File 'lib/ballantine/commit.rb', line 5 def subject @subject end |
Class Method Details
.find(hash:, repo:) ⇒ Commit, NilClass
12 13 14 15 |
# File 'lib/ballantine/commit.rb', line 12 def find(hash:, repo:) @_collections = {} unless defined?(@_collections) @_collections["#{hash[...7]}-#{repo.name}"] end |
.find_or_create_by(hash:, repo:) ⇒ Commit
20 21 22 |
# File 'lib/ballantine/commit.rb', line 20 def find_or_create_by(hash:, repo:) find(hash:, repo:) || @_collections["#{hash[...7]}-#{repo.name}"] = new(hash:, repo:) end |
Instance Method Details
#slack_message ⇒ String
42 43 44 |
# File 'lib/ballantine/commit.rb', line 42 def "\`<#{url}|#{hash}>\` #{subject} - #{.name}" end |
#update(**kwargs) ⇒ Commit
33 34 35 36 37 |
# File 'lib/ballantine/commit.rb', line 33 def update(**kwargs) # TODO: validate keys and values kwargs.each { |key, value| instance_variable_set("@#{key}", value) } self end |
#url ⇒ Object
39 |
# File 'lib/ballantine/commit.rb', line 39 def url; @url ||= "#{repo.url}/commit/#{long_hash}" end |