Class: ActionMessage::Base
- Inherits:
-
AbstractController::Base
- Object
- AbstractController::Base
- ActionMessage::Base
- Includes:
- AbstractController::Callbacks, AbstractController::Logger, AbstractController::Rendering, ActionView::Layouts
- Defined in:
- lib/action_message/base.rb
Instance Attribute Summary collapse
-
#template_name ⇒ Object
Returns the value of attribute template_name.
-
#template_path ⇒ Object
Returns the value of attribute template_path.
Class Method Summary collapse
- .base_paths ⇒ Object
-
.default(value = nil) ⇒ Object
(also: default_options=)
Sets the defaults through app configuration: config.action_message.default(from: “+11231231234”).
Instance Method Summary collapse
- #full_template_path ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #sms(params = {}, &block) ⇒ Object
Constructor Details
#initialize ⇒ Base
58 59 60 61 62 |
# File 'lib/action_message/base.rb', line 58 def initialize super = false = Message.new end |
Instance Attribute Details
#template_name ⇒ Object
Returns the value of attribute template_name.
56 57 58 |
# File 'lib/action_message/base.rb', line 56 def template_name @template_name end |
#template_path ⇒ Object
Returns the value of attribute template_path.
56 57 58 |
# File 'lib/action_message/base.rb', line 56 def template_path @template_path end |
Class Method Details
.base_paths ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/action_message/base.rb', line 39 def base_paths %w( app/views app/views/messages app/views/mailers app/views/application app/views/layouts ).freeze end |
.default(value = nil) ⇒ Object Also known as: default_options=
Sets the defaults through app configuration: config.action_message.default(from: “+11231231234”)
Aliased by ::default_options=
30 31 32 33 |
# File 'lib/action_message/base.rb', line 30 def default(value = nil) self.default_params = default_params.merge(value).freeze if value default_params end |
Instance Method Details
#full_template_path ⇒ Object
81 82 83 |
# File 'lib/action_message/base.rb', line 81 def full_template_path [template_path, template_name].join('/') end |
#sms(params = {}, &block) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/action_message/base.rb', line 64 def sms(params = {}, &block) raise ArgumentError, 'You need to provide at least a receipient' if params[:to].blank? return if && !block self.template_name = params[:template_name].presence || template_name self.template_path = params[:template_path].presence || template_path = true lookup_context.view_paths = (lookup_context.view_paths.to_a + self.class.base_paths).flatten.uniq .to = params[:to] .debug = params[:debug] .body = params[:body] || render(full_template_path) end |