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:
parent
c6b16260fe
commit
5a19d24892
1 changed files with 32 additions and 0 deletions
32
actionmailer/lib/action_mailer/collector.rb
Normal file
32
actionmailer/lib/action_mailer/collector.rb
Normal 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
|
Loading…
Reference in a new issue