module Pushing::Adapters

Constants

ADAPTER_INSTANCES

Hash object that holds referenses to adapter instances.

MUTEX

Mutex object used to ensure the instance method creates a singleton object.

Public Class Methods

instance(configuration) click to toggle source

Provides an adapter instance specified in the configuration. If the adapter is not found in ADAPTER_INSTANCES, it'll look up the adapter class and create a new instance using the configuration.

# File lib/pushing/adapters.rb, line 36
def instance(configuration)
  ADAPTER_INSTANCES[configuration.adapter] || MUTEX.synchronize do
    ADAPTER_INSTANCES[configuration.adapter] ||= lookup(configuration.adapter).new(configuration)
  end
end
lookup(name) click to toggle source

Returns the constant for the specified adapter name.

Pushing::Adapters.lookup(:apnotic)
# => Pushing::Adapters::ApnoticAdapter
# File lib/pushing/adapters.rb, line 28
def lookup(name)
  const_get("#{name.to_s.camelize}Adapter")
end