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
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#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
- #delivery ⇒ Object
-
#initialize(method_name, *params) ⇒ 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, *params) ⇒ Controller
Instanciate a new TextMessage object.
Then calls method_name with the given args.
35 36 37 38 39 40 |
# File 'lib/text_message_rails/controller.rb', line 35 def initialize(method_name, *params) @recipients = [] @params = params super() process(method_name, *params) end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
30 31 32 |
# File 'lib/text_message_rails/controller.rb', line 30 def params @params end |
#recipients ⇒ Object (readonly)
Basic Recipients handling
43 44 45 |
# File 'lib/text_message_rails/controller.rb', line 43 def recipients @recipients end |
Class Method Details
.default_url_options ⇒ Object
Reuses ActionMailer url options by default
58 59 60 |
# File 'lib/text_message_rails/controller.rb', line 58 def || ActionMailer::Base. end |
.default_url_options=(options) ⇒ Object
54 55 56 |
# File 'lib/text_message_rails/controller.rb', line 54 def () = end |
.deliver_text_message(delivery) ⇒ Object
88 89 90 |
# File 'lib/text_message_rails/controller.rb', line 88 def (delivery) provider.(delivery) end |
.method_missing(method_name, *args) ⇒ Object
:nodoc:
80 81 82 83 84 85 86 |
# File 'lib/text_message_rails/controller.rb', line 80 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 !
66 67 68 |
# File 'lib/text_message_rails/controller.rb', line 66 def provider @@provider || TextMessage::Providers::Base end |
.provider=(p) ⇒ Object
62 63 64 |
# File 'lib/text_message_rails/controller.rb', line 62 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.
76 77 78 |
# File 'lib/text_message_rails/controller.rb', line 76 def respond_to?(method, include_private = false) #:nodoc: super || action_methods.include?(method.to_s) end |
Instance Method Details
#delivery ⇒ Object
48 49 50 |
# File 'lib/text_message_rails/controller.rb', line 48 def delivery TextMessage::Delivery.new(self, action_name, *params) end |
#send_to(*recipients) ⇒ Object
44 45 46 |
# File 'lib/text_message_rails/controller.rb', line 44 def send_to(*recipients) @recipients = recipients || [] end |