Class: TextMessage::Controller
- Inherits:
-
AbstractController::Base
- Object
- AbstractController::Base
- TextMessage::Controller
- Includes:
- AbstractController::Callbacks, AbstractController::Helpers, AbstractController::Logger, AbstractController::Rendering, Rendering
- Defined in:
- lib/text_message_rails/controller.rb
Overview
TextMessage controller base class
This class acts as a controller, similar to ActionMailer::Controller
subclasses. To use it:
- implement action methods as in a "usual" controller
class TextMessageTest < TextMessage::Controller
# Will render app/views/sms_test/toto.(...), passing it the instance variables
def toto
@tutu = 4
end
end
Instance Attribute Summary collapse
-
#recipients ⇒ Object
readonly
Basic Recipients handling.
Class Method Summary collapse
-
.default_url_options ⇒ Object
Reuses ActionMailer url options by default.
- .default_url_options=(options) ⇒ Object
- .deliver_text_message(delivery) ⇒ Object
-
.method_missing(method_name, *args) ⇒ Object
:nodoc:.
-
.provider ⇒ Object
Defaults provider to the Base (empty) provider: will raise !.
- .provider=(p) ⇒ Object
-
.respond_to?(method, include_private = false) ⇒ Boolean
Respond to the action methods directly on the class.
Instance Method Summary collapse
-
#initialize(method_name, *args) ⇒ Controller
constructor
Instanciate a new TextMessage object.
- #send_to(*recipients) ⇒ Object
Methods included from Rendering
included, #render_to_body, #renderer, #view_context
Constructor Details
#initialize(method_name, *args) ⇒ Controller
Instanciate a new TextMessage object.
Then calls method_name
with the given args
.
33 34 35 36 37 |
# File 'lib/text_message_rails/controller.rb', line 33 def initialize(method_name, *args) @recipients = [] super() process(method_name, *args) end |
Instance Attribute Details
#recipients ⇒ Object (readonly)
Basic Recipients handling
40 41 42 |
# File 'lib/text_message_rails/controller.rb', line 40 def recipients @recipients end |
Class Method Details
.default_url_options ⇒ Object
Reuses ActionMailer url options by default
51 52 53 |
# File 'lib/text_message_rails/controller.rb', line 51 def @@default_url_options || ActionMailer::Base. end |
.default_url_options=(options) ⇒ Object
47 48 49 |
# File 'lib/text_message_rails/controller.rb', line 47 def () @@default_url_options = end |
.deliver_text_message(delivery) ⇒ Object
81 82 83 |
# File 'lib/text_message_rails/controller.rb', line 81 def (delivery) provider.(delivery) end |
.method_missing(method_name, *args) ⇒ Object
:nodoc:
73 74 75 76 77 78 79 |
# File 'lib/text_message_rails/controller.rb', line 73 def method_missing(method_name, *args) #:nodoc: if action_methods.include?(method_name.to_s) TextMessage::Delivery.new(self, method_name, *args) else super end end |
.provider ⇒ Object
Defaults provider to the Base (empty) provider: will raise !
59 60 61 |
# File 'lib/text_message_rails/controller.rb', line 59 def provider @@provider || TextMessage::Providers::Base end |
.provider=(p) ⇒ Object
55 56 57 |
# File 'lib/text_message_rails/controller.rb', line 55 def provider=(p) @@provider = p end |
.respond_to?(method, include_private = false) ⇒ Boolean
Respond to the action methods directly on the class
for example calling ‘TextMessageDemo.toto` (with TextMessageDemo a subclass of TextMessage::Controller
) will create a TextMessage::Delivery
instance tied to the `TextMessageDemo` class, method `:toto` with no argument.
69 70 71 |
# File 'lib/text_message_rails/controller.rb', line 69 def respond_to?(method, include_private = false) #:nodoc: super || action_methods.include?(method.to_s) end |
Instance Method Details
#send_to(*recipients) ⇒ Object
41 42 43 |
# File 'lib/text_message_rails/controller.rb', line 41 def send_to(*recipients) @recipients = recipients || [] end |