Class: Maia::Message
- Inherits:
-
Object
- Object
- Maia::Message
- Defined in:
- lib/maia/message.rb
Instance Method Summary collapse
- #badge ⇒ Object
- #body ⇒ Object
- #color ⇒ Object
- #content_available? ⇒ Boolean
- #content_mutable? ⇒ Boolean
- #data ⇒ Object
- #dry_run? ⇒ Boolean
- #enqueue(worker, devices) ⇒ Object
- #icon ⇒ Object
- #notification ⇒ Object
- #on_click ⇒ Object
- #priority ⇒ Object
- #send_to(pushable, job_options = {}) ⇒ Object
- #sound ⇒ Object
- #title ⇒ Object
- #to_h ⇒ Object
Instance Method Details
#badge ⇒ Object
34 35 |
# File 'lib/maia/message.rb', line 34 def badge end |
#body ⇒ Object
21 22 |
# File 'lib/maia/message.rb', line 21 def body end |
#color ⇒ Object
37 38 |
# File 'lib/maia/message.rb', line 37 def color end |
#content_available? ⇒ Boolean
47 48 49 |
# File 'lib/maia/message.rb', line 47 def content_available? false end |
#content_mutable? ⇒ Boolean
51 52 53 |
# File 'lib/maia/message.rb', line 51 def content_mutable? false end |
#data ⇒ Object
40 41 |
# File 'lib/maia/message.rb', line 40 def data end |
#dry_run? ⇒ Boolean
55 56 57 |
# File 'lib/maia/message.rb', line 55 def dry_run? false end |
#enqueue(worker, devices) ⇒ Object
12 13 14 15 16 |
# File 'lib/maia/message.rb', line 12 def enqueue(worker, devices) devices.in_batches(of: Maia::BATCH_SIZE) do |devices| worker.perform_later devices.pluck(:token), to_h.deep_stringify_keys end end |
#icon ⇒ Object
27 28 |
# File 'lib/maia/message.rb', line 27 def icon end |
#notification ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/maia/message.rb', line 59 def notification { title: title, body: body, icon: icon, sound: sound.to_s, badge: badge, color: color, click_action: on_click }.compact end |
#on_click ⇒ Object
24 25 |
# File 'lib/maia/message.rb', line 24 def on_click end |
#priority ⇒ Object
43 44 45 |
# File 'lib/maia/message.rb', line 43 def priority :normal end |
#send_to(pushable, job_options = {}) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/maia/message.rb', line 3 def send_to(pushable, = {}) devices = Device.owned_by pushable worker = Messenger.set enqueue worker, devices.android enqueue worker, devices.ios enqueue worker, devices.unknown end |
#sound ⇒ Object
30 31 32 |
# File 'lib/maia/message.rb', line 30 def sound :default end |
#title ⇒ Object
18 19 |
# File 'lib/maia/message.rb', line 18 def title end |
#to_h ⇒ Object
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/maia/message.rb', line 71 def to_h { priority: priority.to_s, dry_run: dry_run?, content_available: content_available?, mutable_content: content_mutable?, data: data, notification: notification }.compact end |