mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Add new MarkerTimelinePresenter
class
This commit is contained in:
parent
aa4d8987a0
commit
c4f7b8b625
1 changed files with 23 additions and 0 deletions
23
app/presenters/marker_timeline_presenter.rb
Normal file
23
app/presenters/marker_timeline_presenter.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class MarkerTimelinePresenter
|
||||
include ActiveModel::Model
|
||||
|
||||
alias read_attribute_for_serialization send
|
||||
|
||||
attr_reader :markers
|
||||
|
||||
def initialize(markers)
|
||||
@markers = markers
|
||||
end
|
||||
|
||||
Marker::TIMELINES.each do |timeline|
|
||||
define_method timeline.to_sym do
|
||||
markers.find { |marker| marker.timeline == timeline }
|
||||
end
|
||||
end
|
||||
|
||||
def timeline_present?(value)
|
||||
markers.map(&:timeline).include?(value)
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue