maia 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODg1MDc0NTUwNDhjMGE1ZDQ4ZjQxZWZhNmY4ZmYzYWI2ZDkzMTM4Mg==
4
+ NzVlMDhkY2RiZjA5YjlhODlhZmFiODM0NmU4NDJhZWQxY2M4NGFhMA==
5
5
  data.tar.gz: !binary |-
6
- ZDQ1Mzc3ODA0NWI2N2QyZGRhMWRjZjM1MDk3Y2UxNGQyYTgzMTgxOQ==
6
+ NDVlNjBhZGY3MTBhYjI4MDJkYmM4NDIwN2IwMmFlM2M4ZGJjMjQyZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzI2ZmIzNzM4ZjVhZDFlOGE3NjUxYmQ4MjgzZGU1YzQyYjc0YjdhNWFhNDE2
10
- MGFkMjhkYTk4ZGVjZjNkMTQxZmJhZjBkM2QxOWRiNjQyMGZmMzgwMTc3MjRm
11
- YjY4NmY3MDlmMDk5MTgzZTRkZGY0MDYxMWI0ZTk1ZWViMzQ1MWM=
9
+ YjI4MDhjMWM1ODgzMjA3MTAzMzU5ZTk4MDE2ZGQzZjViZTFmNjQyYTczZjk4
10
+ NDlkMDY5MmM0MWJiNTdhMmY3ZDJhZDI2ZTZhZmIxNjcyYTI5YjA3OGZhMjk1
11
+ OTZlODg0MGMyYjY5MGEyMGRjZTg2MGVhMTM4NDk5YzQ3YWEwMjI=
12
12
  data.tar.gz: !binary |-
13
- YjY0Yzg3NjNjNWFlNzY2Yjg3MTNkN2U2YWNjMjJkMGU4YmYwYTdiOTM1ZTgw
14
- MmI0NzAwODZlMjEzN2MxZmIxMDRmODU2MDg1ZGNlODI5NDQ1ZTE2OWJkMzcx
15
- YjIwZjYxN2UxMmJhZmNlNjMwZGFjNjFjNjNhMTJiMzU3NTkzOGQ=
13
+ NWViZTVlODljZjVjZDNiMjQzYWRmYjcyYWU5YzE4ZWJiNmQ5Nzk0MDAxNDg3
14
+ NDFkYjJmOWRhOGVlMmEwMjdkMTY5YzIzZDc4YjQzY2Q5MmMyODkxODhhMGYx
15
+ NzI1ODI5NDFmNGYyYzc3YjFkYjc1ODU4ZTY5ZmU1NGM4NGVmNGM=
data/lib/maia/message.rb CHANGED
@@ -2,7 +2,7 @@ module Maia
2
2
  class Message
3
3
  MAX_TOKENS_AT_ONCE = 999
4
4
 
5
- def send_to(pushable)
5
+ def send_to(pushable, wait: false)
6
6
  devices =
7
7
  case pushable
8
8
  when ActiveRecord::Relation
@@ -10,15 +10,17 @@ module Maia
10
10
  when ActiveRecord::Base
11
11
  pushable.devices
12
12
  else
13
- raise ArgumentError.new
13
+ fail 'Maia can only send to ActiveRecord objects!'
14
14
  end
15
15
 
16
- enqueue devices, to_h
16
+ enqueue devices, to_h, wait: wait
17
17
  end
18
18
 
19
- def enqueue(devices, payload)
19
+ def enqueue(devices, payload, wait: false)
20
+ worker = wait ? Maia::Messenger.set(wait: wait) : Maia::Messenger
21
+
20
22
  devices.pluck(:token).each_slice(MAX_TOKENS_AT_ONCE) do |tokens|
21
- Maia::Messenger.perform_later tokens, payload.deep_stringify_keys
23
+ worker.perform_later tokens, payload.deep_stringify_keys
22
24
  end
23
25
  end
24
26
 
data/lib/maia/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Maia
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Logan Serman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-12 00:00:00.000000000 Z
11
+ date: 2016-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails