Class: Loco::Notification::Fetcher

Inherits:
Object
  • Object
show all
Defined in:
app/services/loco/notification/fetcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(synced_at:, permissions: [], recipient_token: nil, max_size: nil) ⇒ Fetcher

Returns a new instance of Fetcher.



5
6
7
8
9
10
11
# File 'app/services/loco/notification/fetcher.rb', line 5

def initialize synced_at:, permissions: [], recipient_token: nil, max_size: nil
  @synced_at = synced_at
  @permissions = permissions
  @recipient_token = recipient_token
  @notifications = nil
  @max_size = max_size || Loco::Config.notifications_size
end

Instance Attribute Details

#max_sizeObject

Returns the value of attribute max_size.



3
4
5
# File 'app/services/loco/notification/fetcher.rb', line 3

def max_size
  @max_size
end

Instance Method Details

#formatted_notificationsObject



13
14
15
# File 'app/services/loco/notification/fetcher.rb', line 13

def formatted_notifications
  notifications.map(&:compact)
end

#next_sync_timeObject



17
18
19
# File 'app/services/loco/notification/fetcher.rb', line 17

def next_sync_time
  notifications.size == max_size ? notifications.last.created_at : Time.current
end