lib/notification_pusher/pusher.rb in notification-pusher-1.2.5 vs lib/notification_pusher/pusher.rb in notification-pusher-1.2.6
- old
+ new
@@ -1,28 +1,27 @@
-module NotificationPusher
- class Pusher
-
- attr_accessor :name
- attr_accessor :options
- attr_accessor :instances
-
- def initialize name, options = {}
- @instances = []
- @name = name
- @options = options
- end
-
- def push notification, options = {}
- default_options = self.options
- options = options.nil? ? default_options : default_options.merge!(options)
- if defined?(NotificationPusher.const_get(self.name))
- instance = NotificationPusher.const_get(self.name).new notification, options
- self.instances << instance
- end
- end
-
- def self.find_by_name name
- NotificationPusher.configuration.pushers.select { |pusher| pusher.name == name }
- end
-
- end
-end
+# frozen_string_literal: true
+
+module NotificationPusher
+ class Pusher
+ attr_reader :name
+
+ def initialize(name, options = {})
+ @instances = []
+ @name = name
+ @options = options
+ end
+
+ def push(notification, options = {})
+ options = @options.merge!(options)
+
+ return unless defined?(NotificationPusher.const_get(@name))
+ instance = NotificationPusher.const_get(@name).new(notification, options)
+ @instances << instance
+ end
+
+ def self.find_by_name(name)
+ NotificationPusher.configuration.pushers.select do |pusher|
+ pusher.name == name
+ end
+ end
+ end
+end