Class: ActionMessageTexter::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/action_message_texter/message.rb

Constant Summary collapse

@@delivery_notification_observers =
[]
@@delivery_interceptors =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMessage

TODO: create registred interceptor and observer



33
34
35
36
# File 'lib/action_message_texter/message.rb', line 33

def initialize
  @raise_delivery_errors = true
  @uuid = SecureRandom.uuid
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



24
25
26
# File 'lib/action_message_texter/message.rb', line 24

def content
  @content
end

#deliver_atObject

Returns the value of attribute deliver_at.



24
25
26
# File 'lib/action_message_texter/message.rb', line 24

def deliver_at
  @deliver_at
end

#delivery_handlerObject

Returns the value of attribute delivery_handler.



24
25
26
# File 'lib/action_message_texter/message.rb', line 24

def delivery_handler
  @delivery_handler
end

#delivery_method(method_klass = nil, settings = {}) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/action_message_texter/message.rb', line 49

def delivery_method(method_klass = nil, settings = {})
  puts method_klass
  if method_klass
    # TODO: get provider from configuration
    @@delivery_method = method_klass.new(settings)
  else
    @@delivery_method
  end
end

#delivery_optionsObject

Returns the value of attribute delivery_options.



24
25
26
# File 'lib/action_message_texter/message.rb', line 24

def delivery_options
  @delivery_options
end

#other_optionsObject

Returns the value of attribute other_options.



24
25
26
# File 'lib/action_message_texter/message.rb', line 24

def other_options
  @other_options
end

#raise_delivery_errorsObject

Returns the value of attribute raise_delivery_errors.



24
25
26
# File 'lib/action_message_texter/message.rb', line 24

def raise_delivery_errors
  @raise_delivery_errors
end

#responseObject

Returns the value of attribute response.



24
25
26
# File 'lib/action_message_texter/message.rb', line 24

def response
  @response
end

#toObject

Returns the value of attribute to.



24
25
26
# File 'lib/action_message_texter/message.rb', line 24

def to
  @to
end

#uuidObject (readonly)

Returns the value of attribute uuid.



29
30
31
# File 'lib/action_message_texter/message.rb', line 29

def uuid
  @uuid
end

Class Method Details

.register_interceptor(interceptor) ⇒ Object



16
17
18
# File 'lib/action_message_texter/message.rb', line 16

def register_interceptor(interceptor)
  @@delivery_interceptors << interceptor unless @@delivery_interceptors.include?(interceptor)
end

.register_observer(observer) ⇒ Object



8
9
10
# File 'lib/action_message_texter/message.rb', line 8

def register_observer(observer)
  @@delivery_notification_observers << observer unless @@delivery_notification_observers.include?(observer)
end

.unregister_interceptor(interceptor) ⇒ Object



20
21
22
# File 'lib/action_message_texter/message.rb', line 20

def unregister_interceptor(interceptor)
  @@delivery_interceptors.delete(interceptor)
end

.unregister_observer(observer) ⇒ Object



12
13
14
# File 'lib/action_message_texter/message.rb', line 12

def unregister_observer(observer)
  @@delivery_notification_observers.delete(observer)
end

Instance Method Details

#deliverObject



38
39
40
41
42
43
44
45
46
47
# File 'lib/action_message_texter/message.rb', line 38

def deliver
  inform_interceptors
  if delivery_handler
    delivery_handler.deliver_message(self) { do_delivery }
  else
    do_delivery
  end
  inform_observers
  response
end