Class: Noticed::BulkDeliveryMethod
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from ApiClient
#post_request
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
8
9
10
|
# File 'lib/noticed/bulk_delivery_method.rb', line 8
def config
@config
end
|
#event ⇒ Object
Returns the value of attribute event.
8
9
10
|
# File 'lib/noticed/bulk_delivery_method.rb', line 8
def event
@event
end
|
Instance Method Details
#deliver ⇒ Object
26
27
28
|
# File 'lib/noticed/bulk_delivery_method.rb', line 26
def deliver
raise NotImplementedError, "Bulk delivery methods must implement the `deliver` method"
end
|
#evaluate_option(name) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/noticed/bulk_delivery_method.rb', line 35
def evaluate_option(name)
option = config[name]
if option&.respond_to?(:call)
event.instance_exec(&option)
elsif option.is_a?(Symbol) && event.respond_to?(option)
event.send(option)
else
option
end
end
|
#fetch_constant(name) ⇒ Object
30
31
32
33
|
# File 'lib/noticed/bulk_delivery_method.rb', line 30
def fetch_constant(name)
option = config[name]
option.is_a?(String) ? option.constantize : option
end
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/noticed/bulk_delivery_method.rb', line 10
def perform(delivery_method_name, event, recipients: nil, params: {}, overrides: {})
if event.is_a? String
@event = @notification.event
@config = overrides
else
@event = event
@config = event.bulk_delivery_methods.fetch(delivery_method_name).config.merge(overrides)
end
return false if config.has_key?(:if) && !evaluate_option(:if)
return false if config.has_key?(:unless) && evaluate_option(:unless)
deliver
end
|