Skip to content
Browse files

Adding collector to ActionMailer

  • Loading branch information...
1 parent c6b1626 commit 5a19d24892b9d842ef7d27875eacecbbad71a9aa José Valim and Mikel Lindsaar committed Jan 23, 2010
Showing with 32 additions and 0 deletions.
  1. +32 −0 actionmailer/lib/action_mailer/collector.rb
View
32 actionmailer/lib/action_mailer/collector.rb
@@ -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

0 comments on commit 5a19d24

Please sign in to comment.
Something went wrong with that request. Please try again.