class TextMessage::Delivery
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.
Public Class Methods
new(text_message_controller, text_message_method, *args)
click to toggle source
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.
# File lib/text_message_rails/delivery.rb, line 14 def initialize(text_message_controller, text_message_method, *args) if text_message_controller.kind_of?(TextMessage::Controller) @obj = text_message_controller @text_message_class = @obj.class else @text_message_class = text_message_controller.kind_of?(Class) ? text_message_controller : text_message_controller.constantize end @text_message_method = text_message_method @args = args end
Public Instance Methods
body()
click to toggle source
computes the body of the TextMessage
# File lib/text_message_rails/delivery.rb, line 31 def body @body ||= renderer.render(view_context, template: "#{templates_dir}/#{@text_message_method}") end
templates_dir()
click to toggle source
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}
# File lib/text_message_rails/delivery.rb, line 40 def templates_dir @text_message_class.name.to_s.underscore end