Module: Rpush::Daemon::ServiceConfigMethods
- Defined in:
- lib/rpush/daemon/service_config_methods.rb
Constant Summary collapse
- DISPATCHERS =
{ http: Rpush::Daemon::Dispatcher::Http, 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
10 11 12 13 |
# File 'lib/rpush/daemon/service_config_methods.rb', line 10 def batch_deliveries(value = nil) return batch_deliveries? if value.nil? @batch_deliveries = value end |
#batch_deliveries? ⇒ Boolean
15 16 17 |
# File 'lib/rpush/daemon/service_config_methods.rb', line 15 def batch_deliveries? @batch_deliveries == true end |
#delivery_class ⇒ Object
28 29 30 |
# File 'lib/rpush/daemon/service_config_methods.rb', line 28 def delivery_class const_get('Delivery') end |
#dispatcher(name = nil, options = {}) ⇒ Object
19 20 21 22 |
# File 'lib/rpush/daemon/service_config_methods.rb', line 19 def dispatcher(name = nil, = {}) @dispatcher_name = name @dispatcher_options = end |
#dispatcher_class ⇒ Object
24 25 26 |
# File 'lib/rpush/daemon/service_config_methods.rb', line 24 def dispatcher_class DISPATCHERS[@dispatcher_name] || (fail NotImplementedError) end |
#loop_instances(app) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/rpush/daemon/service_config_methods.rb', line 41 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
36 37 38 39 |
# File 'lib/rpush/daemon/service_config_methods.rb', line 36 def loops(classes, = {}) classes = Array[*classes] @loops = classes.map { |cls| [cls, ] } end |
#new_dispatcher(app) ⇒ Object
32 33 34 |
# File 'lib/rpush/daemon/service_config_methods.rb', line 32 def new_dispatcher(app) dispatcher_class.new(app, delivery_class, @dispatcher_options) end |