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(opts) ⇒ Fetcher

Returns a new instance of Fetcher.



8
9
10
11
12
13
14
# File 'app/services/loco/notification/fetcher.rb', line 8

def initialize(opts)
  @synced_at = opts[:synced_at]
  @permissions = (opts[:permissions] || []).compact
  @recipient_token = opts[:recipient_token]
  @notifications = nil
  @max_size = opts[:max_size] || Loco::Config.notifications_size
end

Instance Attribute Details

#max_sizeObject

Returns the value of attribute max_size.



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

def max_size
  @max_size
end

Instance Method Details

#formatted_notificationsObject



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

def formatted_notifications
  notifications.map(&:compact)
end

#next_sync_timeObject



20
21
22
23
24
25
26
# File 'app/services/loco/notification/fetcher.rb', line 20

def next_sync_time
  if notifications.size == max_size
    notifications.last.created_at
  else
    Time.current
  end
end