Module: ActsAsPushable::Pushable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/acts_as_pushable/pushable.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #add_device(device_params) ⇒ Object
- #add_device!(device_params) ⇒ Object
- #android_devices ⇒ Object
- #ios_devices ⇒ Object
- #send_push_notification(title:, message:, **options) ⇒ Object
Instance Method Details
#add_device(device_params) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/acts_as_pushable/pushable.rb', line 22 def add_device(device_params) device = build_device(device_params) if device.save return device else device.errors.each do |attribute, | errors.add(:devices, "#{attribute} #{}") end return false end end |
#add_device!(device_params) ⇒ Object
34 35 36 37 38 |
# File 'lib/acts_as_pushable/pushable.rb', line 34 def add_device!(device_params) device = build_device(device_params) device.save! return device end |
#android_devices ⇒ Object
18 19 20 |
# File 'lib/acts_as_pushable/pushable.rb', line 18 def android_devices devices.where(platform: 'android') end |
#ios_devices ⇒ Object
14 15 16 |
# File 'lib/acts_as_pushable/pushable.rb', line 14 def ios_devices devices.where(platform: 'ios') end |
#send_push_notification(title:, message:, **options) ⇒ Object
40 41 42 43 44 |
# File 'lib/acts_as_pushable/pushable.rb', line 40 def send_push_notification(title:, message:, **) devices.each do |device| device.send_push_notification(title: title, message: , **) end end |