Class: ActionMessageTexter::Message
- Inherits:
-
Object
- Object
- ActionMessageTexter::Message
- Defined in:
- lib/action_message_texter/message.rb
Constant Summary collapse
- @@delivery_notification_observers =
[]
- @@delivery_interceptors =
[]
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#deliver_at ⇒ Object
Returns the value of attribute deliver_at.
-
#delivery_handler ⇒ Object
Returns the value of attribute delivery_handler.
- #delivery_method(method_klass = nil, settings = {}) ⇒ Object
-
#delivery_options ⇒ Object
Returns the value of attribute delivery_options.
-
#other_options ⇒ Object
Returns the value of attribute other_options.
-
#raise_delivery_errors ⇒ Object
Returns the value of attribute raise_delivery_errors.
-
#response ⇒ Object
Returns the value of attribute response.
-
#to ⇒ Object
Returns the value of attribute to.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Class Method Summary collapse
- .register_interceptor(interceptor) ⇒ Object
- .register_observer(observer) ⇒ Object
- .unregister_interceptor(interceptor) ⇒ Object
- .unregister_observer(observer) ⇒ Object
Instance Method Summary collapse
- #deliver ⇒ Object
-
#initialize ⇒ Message
constructor
TODO: create registred interceptor and observer.
Constructor Details
#initialize ⇒ Message
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
#content ⇒ Object
Returns the value of attribute content.
24 25 26 |
# File 'lib/action_message_texter/message.rb', line 24 def content @content end |
#deliver_at ⇒ Object
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_handler ⇒ Object
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_options ⇒ Object
Returns the value of attribute delivery_options.
24 25 26 |
# File 'lib/action_message_texter/message.rb', line 24 def @delivery_options end |
#other_options ⇒ Object
Returns the value of attribute other_options.
24 25 26 |
# File 'lib/action_message_texter/message.rb', line 24 def @other_options end |
#raise_delivery_errors ⇒ Object
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 |
#response ⇒ Object
Returns the value of attribute response.
24 25 26 |
# File 'lib/action_message_texter/message.rb', line 24 def response @response end |
#to ⇒ Object
Returns the value of attribute to.
24 25 26 |
# File 'lib/action_message_texter/message.rb', line 24 def to @to end |
#uuid ⇒ Object (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
#deliver ⇒ Object
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.(self) { do_delivery } else do_delivery end inform_observers response end |