Class: Noticed::Ephemeral

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Attributes, ActiveModel::Model, Deliverable, Translation
Defined in:
app/models/noticed/ephemeral.rb

Defined Under Namespace

Classes: Notification

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Translation

#class_scope, #i18n_scope, #scope_translation_key, #translate

Methods included from Deliverable

#deserialize_error?, #evaluate_recipients, #recipient_attributes_for, #validate!, #validate_delivery_methods!, #validate_params!

Class Method Details

.inherited(notifier) ⇒ Object

Dynamically define Notification on each Ephemeral Notifier



31
32
33
34
# File 'app/models/noticed/ephemeral.rb', line 31

def self.inherited(notifier)
  super
  notifier.const_set :Notification, Class.new(Noticed::Ephemeral::Notification)
end

.notification_methods(&block) ⇒ Object



36
37
38
# File 'app/models/noticed/ephemeral.rb', line 36

def self.notification_methods(&block)
  const_get(:Notification).class_eval(&block)
end

Instance Method Details

#deliver(recipients) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/models/noticed/ephemeral.rb', line 40

def deliver(recipients)
  recipients = Array.wrap(recipients)
  bulk_delivery_methods.each do |_, deliver_by|
    deliver_by.ephemeral_perform_later(self.class.name, recipients, params)
  end

  recipients.each do |recipient|
    delivery_methods.each do |_, deliver_by|
      deliver_by.ephemeral_perform_later(self.class.name, recipient, params)
    end
  end
end

#recordObject



53
54
55
# File 'app/models/noticed/ephemeral.rb', line 53

def record
  params[:record]
end