lib/roadie/action_mailer_extensions.rb in roadie-2.0.0 vs lib/roadie/action_mailer_extensions.rb in roadie-2.1.0.pre1
- old
+ new
@@ -14,11 +14,16 @@
end
end
protected
def mail_with_inline_styles(headers = {}, &block)
- @inline_style_css_targets = headers[:css]
+ if headers.has_key?(:css)
+ @targets = headers[:css]
+ else
+ @targets = default_css_targets
+ end
+
mail_without_inline_styles(headers, &block).tap do |email|
email.header.fields.delete_if { |field| field.name == 'css' }
end
end
@@ -26,27 +31,27 @@
responses, order = collect_responses_and_parts_order_without_inline_styles(headers, &block)
[responses.map { |response| inline_style_response(response) }, order]
end
private
+ def default_css_targets
+ self.class.default[:css]
+ end
+
def url_options
Rails.application.config.action_mailer.default_url_options
end
def inline_style_response(response)
if response[:content_type] == 'text/html'
- response.merge :body => Roadie.inline_css(css_rules, response[:body], url_options)
+ response.merge :body => Roadie.inline_css(Roadie.current_provider, css_targets, response[:body], url_options)
else
response
end
end
def css_targets
- return nil if @inline_style_css_targets == false
- Array(@inline_style_css_targets || self.class.default[:css] || []).map { |target| target.to_s }
- end
-
- def css_rules
- @css_rules ||= Roadie.load_css(css_targets) if css_targets.present?
+ return [] unless @targets
+ Array.wrap(@targets || []).map { |target| target.to_s }
end
end
end