Class: Dovado::Router::Sms::Messages

Inherits:
Object
  • Object
show all
Includes:
Celluloid
Defined in:
lib/dovado/router/sms/messages.rb

Overview

Text messages.

Since:

  • 1.0.0

Instance Method Summary collapse

Constructor Details

#initializeMessages

Create a new Dovado::Router::Sms::Messages object.

Since:

  • 1.0.0



13
14
15
# File 'lib/dovado/router/sms/messages.rb', line 13

def initialize
  @messages = ThreadSafe::Cache.new
end

Instance Method Details

#[](id) ⇒ Object

Since:

  • 1.0.0



32
33
34
# File 'lib/dovado/router/sms/messages.rb', line 32

def [](id)
  get_message(id)
end

#add_message(message) ⇒ Object

Add a message to the local cache.

Parameters:

Since:

  • 1.0.0



19
20
21
# File 'lib/dovado/router/sms/messages.rb', line 19

def add_message(message)
  @messages[message.id] = message unless message.nil?
end

#get_message(id) ⇒ Message

Fetch a Dovado::Router::Sms::Message from the cache.

Parameters:

  • id (String, Integer, Symbol)

    Id of the message.

Returns:

See Also:

  • {Message}

Since:

  • 1.0.0



28
29
30
# File 'lib/dovado/router/sms/messages.rb', line 28

def get_message(id)
  @messages[id] unless id.nil?
end

#idsObject

Since:

  • 1.0.0



36
37
38
# File 'lib/dovado/router/sms/messages.rb', line 36

def ids
  @messages.keys
end