1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Adding collector to ActionMailer

This commit is contained in:
José Valim and Mikel Lindsaar 2010-01-23 21:50:36 +11:00
parent c6b16260fe
commit 5a19d24892

View file

@ -0,0 +1,32 @@
require 'abstract_controller/collector'
module ActionMailer #:nodoc:
class Collector
include AbstractController::Collector
attr_accessor :responses
def initialize(context, options, &block)
@default_options = options
@default_render = block
@default_formats = context.formats
@context = context
@responses = []
end
def custom(mime, options={}, &block)
options = @default_options.merge(:content_type => mime.to_s).merge(options)
@context.formats = [mime.to_sym]
options[:body] = if block
block.call
else
@default_render.call
end
@responses << options
@context.formats = @default_formats
end
end
end