Module: Rpush::Daemon::ServiceConfigMethods
- Defined in:
- lib/rpush/daemon/service_config_methods.rb
Constant Summary collapse
- 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 }
Instance Method Summary collapse
- #batch_deliveries(value = nil) ⇒ Object
- #batch_deliveries? ⇒ Boolean
- #delivery_class ⇒ Object
- #dispatcher(name = nil, options = {}) ⇒ Object
- #dispatcher_class ⇒ Object
- #loop_instances(app) ⇒ Object
- #loops(classes, options = {}) ⇒ Object
- #new_dispatcher(app) ⇒ Object
Instance Method Details
#batch_deliveries(value = nil) ⇒ Object
12 13 14 15 |
# File 'lib/rpush/daemon/service_config_methods.rb', line 12 def batch_deliveries(value = nil) return batch_deliveries? if value.nil? @batch_deliveries = value end |
#batch_deliveries? ⇒ Boolean
17 18 19 |
# File 'lib/rpush/daemon/service_config_methods.rb', line 17 def batch_deliveries? @batch_deliveries == true end |
#delivery_class ⇒ Object
30 31 32 |
# File 'lib/rpush/daemon/service_config_methods.rb', line 30 def delivery_class const_get('Delivery') end |
#dispatcher(name = nil, options = {}) ⇒ Object
21 22 23 24 |
# File 'lib/rpush/daemon/service_config_methods.rb', line 21 def dispatcher(name = nil, = {}) @dispatcher_name = name = end |
#dispatcher_class ⇒ Object
26 27 28 |
# File 'lib/rpush/daemon/service_config_methods.rb', line 26 def dispatcher_class DISPATCHERS[@dispatcher_name] || (fail NotImplementedError) end |
#loop_instances(app) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/rpush/daemon/service_config_methods.rb', line 43 def loop_instances(app) (@loops || []).map do |cls, | next unless .key?(:if) ? [:if].call : true cls.new(app) end.compact end |
#loops(classes, options = {}) ⇒ Object
38 39 40 41 |
# File 'lib/rpush/daemon/service_config_methods.rb', line 38 def loops(classes, = {}) classes = Array[*classes] @loops = classes.map { |cls| [cls, ] } end |
#new_dispatcher(app) ⇒ Object
34 35 36 |
# File 'lib/rpush/daemon/service_config_methods.rb', line 34 def new_dispatcher(app) dispatcher_class.new(app, delivery_class, ) end |