Understanding ActionMailer::Base.new

While writing a small plugin I stumbled upon this strangeness. I have
TMail objects stored in database for process that sends them out
whenever needed.

Obvious way of sending them out would be calling
ActionMailer::Base.deliver(my_mail_object)

That works just fine. However I have method chain hooking into instance
method deliver!:

alias_method_chain :deliver!, :something_crazy

so I need to send directly using deliver_without_something_crazy!
method. Easy, right? All that I need to do is call:
ActionMailer::Base.new.deliver_without_something_crazy!(my_mail_object)

Problem is that ActionMailer::Base.new returns nil for whatever reason.
That doesn’t make much sense to me because this is the definition of
deliver method:

ActionMailer::Base.deliver(mail)
new.deliver!(mail)
end

So, if I return/raise ‘new’ inside that function it actually returns
ActionMailer::Base object instead of nil. As far as I can see those
should be identical calls, returning the same result.

Can anybody shine some light on this?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs