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
- #find_trailer(key) ⇒ Object
- #find_trailers(key) ⇒ Object
- #trailer_value_for(key) ⇒ Object
- #trailer_values_for(key) ⇒ Object
Instance Method Details
#find_trailer(key) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/gitt/trailable.rb', line 6 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
15 16 17 18 |
# File 'lib/gitt/trailable.rb', line 15 def find_trailers key trailers.select { |trailer| trailer.key == key } .then { |trailers| Success trailers } end |
#trailer_value_for(key) ⇒ Object
20 |
# File 'lib/gitt/trailable.rb', line 20 def trailer_value_for(key) = find_trailer(key).fmap(&:value) |
#trailer_values_for(key) ⇒ Object
22 |
# File 'lib/gitt/trailable.rb', line 22 def trailer_values_for(key) = find_trailers(key).fmap { |trailers| trailers.map(&:value) } |