Class: ActionShortMessage::ShortMessage
- Inherits:
-
Object
- Object
- ActionShortMessage::ShortMessage
- Defined in:
- lib/action_short_message/short_message.rb
Overview
include ActionShortMessage::Adapters
Constant Summary collapse
- @@delivery_notification_observers =
Initialize the observers and interceptors arrays
[]
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#message ⇒ Object
Returns the value of attribute message.
-
#options ⇒ Object
Returns the value of attribute options.
-
#raise_delivery_errors ⇒ Object
Returns the value of attribute raise_delivery_errors.
-
#sms_provider(method = nil, settings = {}) ⇒ Object
readonly
Returns the value of attribute sms_provider.
-
#to ⇒ Object
Returns the value of attribute to.
Class Method Summary collapse
- .delivery_adapters ⇒ Object
-
.register_observer(observer) ⇒ Object
You can register an object to be informed of every short message that is sent through this method.
-
.unregister_observer(observer) ⇒ Object
Unregister the given observer, allowing short message to resume operations without it.
Instance Method Summary collapse
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
5 6 7 |
# File 'lib/action_short_message/short_message.rb', line 5 def action @action end |
#debug ⇒ Object
Returns the value of attribute debug.
5 6 7 |
# File 'lib/action_short_message/short_message.rb', line 5 def debug @debug end |
#message ⇒ Object
Returns the value of attribute message.
5 6 7 |
# File 'lib/action_short_message/short_message.rb', line 5 def @message end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/action_short_message/short_message.rb', line 5 def @options end |
#raise_delivery_errors ⇒ Object
Returns the value of attribute raise_delivery_errors.
5 6 7 |
# File 'lib/action_short_message/short_message.rb', line 5 def raise_delivery_errors @raise_delivery_errors end |
#sms_provider(method = nil, settings = {}) ⇒ Object (readonly)
Returns the value of attribute sms_provider.
6 7 8 |
# File 'lib/action_short_message/short_message.rb', line 6 def sms_provider @sms_provider end |
#to ⇒ Object
Returns the value of attribute to.
5 6 7 |
# File 'lib/action_short_message/short_message.rb', line 5 def to @to end |
Class Method Details
.delivery_adapters ⇒ Object
36 |
# File 'lib/action_short_message/short_message.rb', line 36 def self.delivery_adapters; end |
.register_observer(observer) ⇒ Object
You can register an object to be informed of every short message that is sent through this method.
Your object needs to respond to a single method #delivered_message(message) which receives the short message that is sent.
20 21 22 |
# File 'lib/action_short_message/short_message.rb', line 20 def self.register_observer(observer) @@delivery_notification_observers << observer unless @@delivery_notification_observers.include?(observer) end |
.unregister_observer(observer) ⇒ Object
Unregister the given observer, allowing short message to resume operations without it.
26 27 28 |
# File 'lib/action_short_message/short_message.rb', line 26 def self.unregister_observer(observer) @@delivery_notification_observers.delete(observer) end |
Instance Method Details
#debug? ⇒ Boolean
38 39 40 |
# File 'lib/action_short_message/short_message.rb', line 38 def debug? !!@debug end |
#deliver ⇒ Object
42 43 44 45 46 47 |
# File 'lib/action_short_message/short_message.rb', line 42 def deliver ActiveSupport::Notifications.instrument('deliver.action_short_message', { messagage: , to: to }) do @sms_provider.(, .merge(to: to)) end inform_observers end |
#inform_observers ⇒ Object
30 31 32 33 34 |
# File 'lib/action_short_message/short_message.rb', line 30 def inform_observers @@delivery_notification_observers.each do |observer| observer.(self) end end |