Class: Compass::Notification::Provider
- Inherits:
-
Object
- Object
- Compass::Notification::Provider
- Includes:
- JsonFormatter, MustImplement
- Defined in:
- lib/compass/notification/provider.rb
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
- #fetch ⇒ Object
- #hash ⇒ Object
-
#initialize(**context) ⇒ Provider
constructor
A new instance of Provider.
- #label ⇒ Object
- #notifications ⇒ Object
- #updated_at ⇒ Object
Methods included from MustImplement
Constructor Details
#initialize(**context) ⇒ Provider
Returns a new instance of Provider.
9 10 11 12 |
# File 'lib/compass/notification/provider.rb', line 9 def initialize(**context) @context = context context.each { |key, value| define_singleton_method(key) { value } } end |
Instance Method Details
#as_json(options = {}) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/compass/notification/provider.rb', line 31 def as_json( = {}) { label: label, notifications: notifications }.compact.as_json() end |
#fetch ⇒ Object
25 |
# File 'lib/compass/notification/provider.rb', line 25 def fetch = must_implement(:fetch) |
#hash ⇒ Object
14 15 16 |
# File 'lib/compass/notification/provider.rb', line 14 def hash notifications.pluck(:id).hash end |
#label ⇒ Object
27 |
# File 'lib/compass/notification/provider.rb', line 27 def label = must_implement(:label) |
#notifications ⇒ Object
18 19 20 21 22 23 |
# File 'lib/compass/notification/provider.rb', line 18 def notifications @notifications ||= Array(fetch).map { |notification| format(notification) } rescue => e log_error(e) [] end |
#updated_at ⇒ Object
29 |
# File 'lib/compass/notification/provider.rb', line 29 def updated_at = must_implement(:updated_at) |