module Pushwoosh::Configurable

Attributes

application[RW]
auth[RW]

Public Class Methods

keys() click to toggle source
# File lib/pushwoosh/configurable.rb, line 14
def keys
  @keys ||= [
    :application,
    :auth,
  ]
end

Public Instance Methods

configure() { |self| ... } click to toggle source
# File lib/pushwoosh/configurable.rb, line 23
def configure
  yield self
  validate_credential_type!
  self
end

Private Instance Methods

credentials() click to toggle source

@return [Hash]

# File lib/pushwoosh/configurable.rb, line 32
def credentials
  {
    application: @application,
    auth:        @auth
  }
end
options() click to toggle source

@return [Hash]

# File lib/pushwoosh/configurable.rb, line 40
def options
  Hash[Pushwoosh::Configurable.keys.map{|key| [key, instance_variable_get(:"@#{key}")]}]
end
validate_credential_type!() click to toggle source
# File lib/pushwoosh/configurable.rb, line 44
def validate_credential_type!
  credentials.each do |credential, value|
    next if value.nil?

    unless value.is_a?(String) || value.is_a?(Symbol)
      raise StandardError, "Invalid #{credential} specified: #{value} must be a string or symbol."
    end
  end
end