diff options
Diffstat (limited to 'actionmailer/lib/action_mailer/deprecated_body.rb')
-rw-r--r-- | actionmailer/lib/action_mailer/deprecated_body.rb | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/actionmailer/lib/action_mailer/deprecated_body.rb b/actionmailer/lib/action_mailer/deprecated_body.rb index 5379b33a54..daaf145327 100644 --- a/actionmailer/lib/action_mailer/deprecated_body.rb +++ b/actionmailer/lib/action_mailer/deprecated_body.rb @@ -1,6 +1,6 @@ module ActionMailer # TODO Remove this module all together in a next release. Ensure that super - # hooks and @assigns_set in ActionMailer::Base are removed as well. + # hooks in ActionMailer::Base are removed as well. module DeprecatedBody extend ActionMailer::AdvAttrAccessor @@ -14,20 +14,27 @@ module ActionMailer end def attachment(params, &block) + if params[:data] + ActiveSupport::Deprecation.warn('attachment :data => "string" is deprecated. To set the body of an attachment ' << + 'please use :content instead, like attachment :content => "string"', caller[0,10]) + params[:content] = params.delete(:data) + end if params[:body] - ActiveSupport::Deprecation.warn('attachment :body => "string" is deprecated. To set the body of an attachment ' << - 'please use :data instead, like attachment :data => "string"', caller[0,10]) - params[:data] = params.delete(:body) + ActiveSupport::Deprecation.warn('attachment :data => "string" is deprecated. To set the body of an attachment ' << + 'please use :content instead, like attachment :content => "string"', caller[0,10]) + params[:content] = params.delete(:body) end end def create_parts - if String === @body && !defined?(@assigns_set) + if String === @body ActiveSupport::Deprecation.warn('body(String) is deprecated. To set the body with a text ' << 'call render(:text => "body")', caller[0,10]) self.response_body = @body - elsif self.response_body - @body = self.response_body + elsif @body.is_a?(Hash) && !@body.empty? + ActiveSupport::Deprecation.warn('body(Hash) is deprecated. Use instance variables to define ' << + 'assigns in your view', caller[0,10]) + @body.each { |k, v| instance_variable_set(:"@#{k}", v) } end end |