File: action_push_native.rb

package info (click to toggle)
ruby-noticed 3.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 324 kB
  • sloc: ruby: 1,186; makefile: 4
file content (24 lines) | stat: -rw-r--r-- 770 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module Noticed
  module DeliveryMethods
    class ActionPushNative < DeliveryMethod
      required_options :devices, :format

      def deliver
        notification = (!!evaluate_option(:silent)) ? notification_class.silent : notification_class

        notification
          .with_apple(evaluate_option(:with_apple))
          .with_google(evaluate_option(:with_google))
          .with_data(evaluate_option(:with_data))
          .new(**evaluate_option(:format))
          .deliver_later_to(evaluate_option(:devices))
      end

      def notification_class
        fetch_constant(:class) || ApplicationPushNotification
      end
    end
  end
end

ActiveSupport.run_load_hooks :noticed_delivery_methods_action_push_native, Noticed::DeliveryMethods::ActionPushNative