Class: Noticed::Ephemeral

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

Defined Under Namespace

Classes: Notification

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Deliverable

#recipient_attributes_for, #validate!, #validate_delivery_methods!, #validate_params!

Class Method Details

.inherited(notifier) ⇒ Object

Dynamically define Notification on each Ephemeral Notifier



27
28
29
30
# File 'app/models/noticed/ephemeral.rb', line 27

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

Instance Method Details

#deliver(recipients) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/models/noticed/ephemeral.rb', line 32

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

#notification_methods(&block) ⇒ Object



49
50
51
# File 'app/models/noticed/ephemeral.rb', line 49

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

#recordObject



45
46
47
# File 'app/models/noticed/ephemeral.rb', line 45

def record
  params[:record]
end