Module: Gitt::Trailable

Included in:
Models::Commit, Models::Tag
Defined in:
lib/gitt/trailable.rb

Overview

Provides shared behavior for objects that have trailers.

Instance Method Summary collapse

Instance Method Details

#find_trailer(key) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/gitt/trailable.rb', line 10

def find_trailer key
  trailers.find { |trailer| trailer.key == key }
          .then do |trailer|
            return Success trailer if trailer

            Failure "Unable to find trailer for key: #{key.inspect}."
          end
end

#find_trailers(key) ⇒ Object



19
20
21
22
# File 'lib/gitt/trailable.rb', line 19

def find_trailers key
  trailers.select { |trailer| trailer.key == key }
          .then { |trailers| Success trailers }
end

#trailer_value_for(key) ⇒ Object



24
# File 'lib/gitt/trailable.rb', line 24

def trailer_value_for(key) = find_trailer(key).fmap(&:value)

#trailer_values_for(key) ⇒ Object



26
# File 'lib/gitt/trailable.rb', line 26

def trailer_values_for(key) = find_trailers(key).fmap { |trailers| trailers.map(&:value) }