Module: Pling
- Defined in:
- lib/pling.rb,
lib/pling/apn.rb,
lib/pling/gcm.rb,
lib/pling/c2dm.rb,
lib/pling/device.rb,
lib/pling/adapter.rb,
lib/pling/gateway.rb,
lib/pling/message.rb,
lib/pling/version.rb,
lib/pling/middleware.rb,
lib/pling/apn/gateway.rb,
lib/pling/gcm/gateway.rb,
lib/pling/adapter/base.rb,
lib/pling/apn/feedback.rb,
lib/pling/c2dm/gateway.rb,
lib/pling/configurable.rb,
lib/pling/apn/connection.rb,
lib/pling/middleware/base.rb,
lib/pling/delayed_initializer.rb
Defined Under Namespace
Modules: APN, Adapter, C2DM, Configurable, GCM, Middleware Classes: AuthenticationFailed, DelayedInitializer, DeliveryFailed, Device, Error, Gateway, Message, NoGatewayFound
Constant Summary collapse
- VERSION =
"0.5.1"
Class Attribute Summary collapse
-
.adapter ⇒ Pling::Adapter
Stores the adapter.
-
.gateways ⇒ Array
Stores the list of available gateway instances.
-
.logger ⇒ Logger
Stores the logger.
-
.middlewares ⇒ Array
Stores the list of avaiable middleware instances.
Class Method Summary collapse
-
._convert(object, type) ⇒ Object
- INTERNAL METHOD
-
Converts the given object to the given pling type.
-
.configure {|config| ... } ⇒ Object
Allows configuration of Pling by passing a config object to the given block.
-
.deliver(message, device, stack = nil) ⇒ Object
Delivers the given message to the given device using the given stack.
Class Attribute Details
.adapter ⇒ Pling::Adapter
Stores the adapter
62 63 64 |
# File 'lib/pling.rb', line 62 def adapter @adapter end |
.gateways ⇒ Array
Stores the list of available gateway instances
42 43 44 |
# File 'lib/pling.rb', line 42 def gateways @gateways end |
.logger ⇒ Logger
Stores the logger. Defaults to Logger.new(nil)
68 69 70 |
# File 'lib/pling.rb', line 68 def logger @logger end |
.middlewares ⇒ Array
Stores the list of avaiable middleware instances
52 53 54 |
# File 'lib/pling.rb', line 52 def middlewares @middlewares end |
Class Method Details
._convert(object, type) ⇒ Object
- INTERNAL METHOD
-
Converts the given object to the given pling type
106 107 108 109 110 |
# File 'lib/pling.rb', line 106 def _convert(object, type) method = :"to_pling_#{type}" raise ArgumentError, "Instances of #{object.class} do not implement ##{method}" unless object.respond_to?(method) object && object.send(method) end |
.configure {|config| ... } ⇒ Object
Allows configuration of Pling by passing a config object to the given block
75 76 77 78 |
# File 'lib/pling.rb', line 75 def configure raise ArgumentError, 'No block given for Pling.configure' unless block_given? yield self end |
.deliver(message, device, stack = nil) ⇒ Object
Delivers the given message to the given device using the given stack.
86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/pling.rb', line 86 def deliver(, device, stack = nil) = Pling._convert(, :message) device = Pling._convert(device, :device) Pling.logger.info "#{self.class} -- Delivering #{.inspect} to #{device.inspect}" stack ||= middlewares.initialize! + [adapter] stack.shift.deliver(, device) do |m, d| deliver(m, d, stack) end end |