Sha256: 15c7c6e7daa4545bc7166b40822fb555d1238fca42053af91079c217e5b4d836

Contents?: true

Size: 1.18 KB

Versions: 26

Compression:

Stored size: 1.18 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
      }

      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

26 entries across 26 versions & 1 rubygems

Version Path
rpush-2.7.0-java lib/rpush/daemon/service_config_methods.rb
rpush-2.7.0 lib/rpush/daemon/service_config_methods.rb
rpush-2.6.0-java lib/rpush/daemon/service_config_methods.rb
rpush-2.6.0 lib/rpush/daemon/service_config_methods.rb
rpush-2.5.0 lib/rpush/daemon/service_config_methods.rb
rpush-2.4.0-java lib/rpush/daemon/service_config_methods.rb
rpush-2.4.0 lib/rpush/daemon/service_config_methods.rb
rpush-2.3.2-java lib/rpush/daemon/service_config_methods.rb
rpush-2.3.2 lib/rpush/daemon/service_config_methods.rb
rpush-2.3.1-java lib/rpush/daemon/service_config_methods.rb
rpush-2.3.1 lib/rpush/daemon/service_config_methods.rb
rpush-2.3.0-java lib/rpush/daemon/service_config_methods.rb
rpush-2.3.0 lib/rpush/daemon/service_config_methods.rb
rpush-2.3.0.rc1 lib/rpush/daemon/service_config_methods.rb
rpush-2.2.0-java lib/rpush/daemon/service_config_methods.rb
rpush-2.2.0 lib/rpush/daemon/service_config_methods.rb
rpush-2.1.0-java lib/rpush/daemon/service_config_methods.rb
rpush-2.1.0 lib/rpush/daemon/service_config_methods.rb
rpush-2.0.1-java lib/rpush/daemon/service_config_methods.rb
rpush-2.0.1 lib/rpush/daemon/service_config_methods.rb