Class: ActionTexter::Client Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/action_texter/client.rb

Overview

This class is abstract.

Parent class for all SMS clients.

Direct Known Subclasses

NexmoClient, TestClient, TwilioClient

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.defaultObject


8
9
10
# File 'lib/action_texter/client.rb', line 8

def self.default
  @default
end

.default=(client) ⇒ Object


12
13
14
# File 'lib/action_texter/client.rb', line 12

def self.default=(client)
  @default = client
end

.setup(provider, *attrs) ⇒ Object


16
17
18
19
20
21
22
23
24
# File 'lib/action_texter/client.rb', line 16

def self.setup(provider, *attrs)
  provider_client =
      begin
        ActionTexter.const_get(provider + "Client")
      rescue NameError
        raise "Provider #{provider} doesn't exist."
      end
  self.default = provider_client.new(*attrs)
end

Instance Method Details

#deliver(message) ⇒ Object

Deliver a message

Raises:

  • (NotImplementedError)

29
30
31
# File 'lib/action_texter/client.rb', line 29

def deliver(message)
  raise NotImplementedError.new("should be implemented by subclasses")
end

#to_sObject


34
35
36
# File 'lib/action_texter/client.rb', line 34

def to_s
  "#<#{self.class.name}:#{object_id}>"
end