Class: Loco::Notification::Fetcher
- Inherits:
-
Object
- Object
- Loco::Notification::Fetcher
- Defined in:
- app/services/loco/notification/fetcher.rb
Instance Attribute Summary collapse
-
#max_size ⇒ Object
Returns the value of attribute max_size.
Instance Method Summary collapse
- #formatted_notifications ⇒ Object
-
#initialize(opts) ⇒ Fetcher
constructor
A new instance of Fetcher.
- #next_sync_time ⇒ Object
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_size ⇒ Object
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_notifications ⇒ Object
16 17 18 |
# File 'app/services/loco/notification/fetcher.rb', line 16 def formatted_notifications notifications.map(&:compact) end |
#next_sync_time ⇒ Object
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 |