2009-10-21 19:05:55 -04:00
|
|
|
module ActionMailer
|
|
|
|
# TODO Remove this module all together in a next release. Ensure that super
|
2010-01-18 19:15:57 -05:00
|
|
|
# hooks and @assigns_set in ActionMailer::Base are removed as well.
|
2009-10-21 19:05:55 -04:00
|
|
|
module DeprecatedBody
|
2010-01-18 19:15:57 -05:00
|
|
|
extend ActionMailer::AdvAttrAccessor
|
|
|
|
|
|
|
|
# Define the body of the message. This is either a Hash (in which case it
|
|
|
|
# specifies the variables to pass to the template when it is rendered),
|
|
|
|
# or a string, in which case it specifies the actual text of the message.
|
|
|
|
adv_attr_accessor :body
|
2009-10-21 19:05:55 -04:00
|
|
|
|
|
|
|
def initialize_defaults(method_name)
|
|
|
|
@body ||= {}
|
|
|
|
end
|
|
|
|
|
2009-12-27 06:09:20 -05:00
|
|
|
def attachment(params, &block)
|
|
|
|
if params[:body]
|
|
|
|
ActiveSupport::Deprecation.warn('attachment :body => "string" is deprecated. To set the body of an attachment ' <<
|
2010-01-18 19:15:57 -05:00
|
|
|
'please use :data instead, like attachment :data => "string"', caller[0,10])
|
2009-12-27 06:09:20 -05:00
|
|
|
params[:data] = params.delete(:body)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-10-21 19:05:55 -04:00
|
|
|
def create_parts
|
2010-01-18 19:15:57 -05:00
|
|
|
if String === @body && !defined?(@assigns_set)
|
|
|
|
ActiveSupport::Deprecation.warn('body(String) is deprecated. To set the body with a text ' <<
|
|
|
|
'call render(:text => "body")', caller[0,10])
|
2009-10-21 19:05:55 -04:00
|
|
|
self.response_body = @body
|
2010-01-18 19:15:57 -05:00
|
|
|
elsif self.response_body
|
|
|
|
@body = self.response_body
|
2009-10-21 19:05:55 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def render(*args)
|
|
|
|
options = args.last.is_a?(Hash) ? args.last : {}
|
|
|
|
if options[:body]
|
2010-01-18 19:15:57 -05:00
|
|
|
ActiveSupport::Deprecation.warn(':body in render deprecated. Please call body ' <<
|
|
|
|
'with a hash instead', caller[0,1])
|
2009-10-21 19:05:55 -04:00
|
|
|
|
2010-01-18 19:15:57 -05:00
|
|
|
body options.delete(:body)
|
2009-10-21 19:05:55 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|