Class: TextMessage::Delivery
- Inherits:
-
Delegator
- Object
- Delegator
- TextMessage::Delivery
- Includes:
- DeliveryMethods
- Defined in:
- lib/text_message_rails/delivery.rb
Overview
TextMessage Delivery Proxy
The Delivery class is the class returned by the TextMessage::Base actions. It is used to enable lazy processing of the actions.
Instance Method Summary collapse
-
#__getobj__ ⇒ Object
Needed by Decorator superclass.
-
#body ⇒ Object
computes the body of the TextMessage.
-
#initialize(text_message_class, text_message_method, *args) ⇒ Delivery
constructor
Creates a new
Deliveryproxy. -
#templates_dir ⇒ Object
The name of the templates which holds the templates.
Methods included from DeliveryMethods
#deliver_later!, #deliver_now!
Constructor Details
#initialize(text_message_class, text_message_method, *args) ⇒ Delivery
Creates a new Delivery proxy. By providing a TextMessage::Base subclass text_message_class, a method name to call text_message_method and a set of arguments to this method args, we allow for lazy processing of the text_message action.
14 15 16 17 18 |
# File 'lib/text_message_rails/delivery.rb', line 14 def initialize(, , *args) = .kind_of?(Class) ? : .constantize = @args = args end |
Instance Method Details
#__getobj__ ⇒ Object
Needed by Decorator superclass
21 22 23 |
# File 'lib/text_message_rails/delivery.rb', line 21 def __getobj__ #:nodoc: @obj ||= .send(:new, , *@args) end |
#body ⇒ Object
computes the body of the TextMessage
26 27 28 |
# File 'lib/text_message_rails/delivery.rb', line 26 def body renderer.render(view_context, template: "#{templates_dir}/#{@text_message_method}") end |
#templates_dir ⇒ Object
The name of the templates which holds the templates. Usually it is the name of the class with underscores, something like:
TextMessageDemo.new.templates_dir => "text_message demo"
# so for exemple TextMessageDemo#toto will lookup for text_message_demo/toto{.text.erb}
35 36 37 |
# File 'lib/text_message_rails/delivery.rb', line 35 def templates_dir .to_s.underscore end |