Sha256: ab98bcab9c472f35f0946115af7b0342fe3b1e463db4f99b814e5f0e63e52613

Contents?: true

Size: 1.31 KB

Versions: 24

Compression:

Stored size: 1.31 KB

Contents

module Rpush
  module Daemon
    module ServiceConfigMethods
      DISPATCHERS = {
        http:       Rpush::Daemon::Dispatcher::Http,
        tcp:        Rpush::Daemon::Dispatcher::Tcp,
        apns_tcp:   Rpush::Daemon::Dispatcher::ApnsTcp,
        apns_http2: Rpush::Daemon::Dispatcher::ApnsHttp2,
        apnsp8_http2: Rpush::Daemon::Dispatcher::Apnsp8Http2
      }

      def batch_deliveries(value = nil)
        return batch_deliveries? if value.nil?
        @batch_deliveries = value
      end

      def batch_deliveries?
        @batch_deliveries == true
      end

      def dispatcher(name = nil, options = {})
        @dispatcher_name = name
        @dispatcher_options = options
      end

      def dispatcher_class
        DISPATCHERS[@dispatcher_name] || (fail NotImplementedError)
      end

      def delivery_class
        const_get('Delivery')
      end

      def new_dispatcher(app)
        dispatcher_class.new(app, delivery_class, @dispatcher_options)
      end

      def loops(classes, options = {})
        classes = Array[*classes]
        @loops = classes.map { |cls| [cls, options] }
      end

      def loop_instances(app)
        (@loops || []).map do |cls, options|
          next unless options.key?(:if) ? options[:if].call : true
          cls.new(app)
        end.compact
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
rpush-8.0.0 lib/rpush/daemon/service_config_methods.rb
rpush-7.0.1 lib/rpush/daemon/service_config_methods.rb
rpush-7.0.0 lib/rpush/daemon/service_config_methods.rb
rpush-6.0.1 lib/rpush/daemon/service_config_methods.rb
rpush-6.0.0 lib/rpush/daemon/service_config_methods.rb
rpush-5.4.0 lib/rpush/daemon/service_config_methods.rb
rpush-5.3.0 lib/rpush/daemon/service_config_methods.rb
rpush-5.2.0 lib/rpush/daemon/service_config_methods.rb
rpush-5.1.0 lib/rpush/daemon/service_config_methods.rb
rpush-5.0.0 lib/rpush/daemon/service_config_methods.rb
rpush-4.2.0 lib/rpush/daemon/service_config_methods.rb
rpush-4.1.1 lib/rpush/daemon/service_config_methods.rb
rpush-4.1.0 lib/rpush/daemon/service_config_methods.rb
rpush-4.0.1 lib/rpush/daemon/service_config_methods.rb
rpush-4.0.0 lib/rpush/daemon/service_config_methods.rb
rpush-3.3.1 lib/rpush/daemon/service_config_methods.rb
rpush-3.3.0 lib/rpush/daemon/service_config_methods.rb
rpush_extended-3.2.6 lib/rpush/daemon/service_config_methods.rb
rpush_extended-3.2.5 lib/rpush/daemon/service_config_methods.rb
rpush-3.2.4 lib/rpush/daemon/service_config_methods.rb