Module: MadMimiTwo::ClassMethods
- Defined in:
- lib/mad_mimi_two/mad_mimi_mailer.rb
Instance Attribute Summary collapse
-
#method_prefix ⇒ Object
Returns the value of attribute method_prefix.
-
#use_erb ⇒ Object
Returns the value of attribute use_erb.
Instance Method Summary collapse
- #deliver_mimi_mail(method, *parameters) ⇒ Object
- #method_missing(method_symbol, *parameters) ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_symbol, *parameters) ⇒ Object
252 253 254 255 256 257 258 259 260 |
# File 'lib/mad_mimi_two/mad_mimi_mailer.rb', line 252 def method_missing(method_symbol, *parameters) if method_prefix && method_symbol.id2name.match(/^deliver_(#{method_prefix}_[_a-z]\w*)/) deliver_mimi_mail($1, *parameters) elsif method_prefix.nil? && method_symbol.id2name.match(/^deliver_([_a-z]\w*)/) deliver_mimi_mail($1, *parameters) else super end end |
Instance Attribute Details
#method_prefix ⇒ Object
Returns the value of attribute method_prefix.
250 251 252 |
# File 'lib/mad_mimi_two/mad_mimi_mailer.rb', line 250 def method_prefix @method_prefix end |
#use_erb ⇒ Object
Returns the value of attribute use_erb.
250 251 252 |
# File 'lib/mad_mimi_two/mad_mimi_mailer.rb', line 250 def use_erb @use_erb end |
Instance Method Details
#deliver_mimi_mail(method, *parameters) ⇒ Object
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/mad_mimi_two/mad_mimi_mailer.rb', line 262 def deliver_mimi_mail(method, *parameters) mail = new mail.__send__(method, *parameters) if use_erb?(mail) mail.create!(method, *parameters) end return unless perform_deliveries if delivery_method == :test deliveries << (mail.mail ? mail.mail : mail) else if (all_recipients = mail.recipients).is_a? Array all_recipients.each do |recipient| mail.recipients = recipient call_api!(mail, method) end else call_api!(mail, method) end end end |