From 5a19d24892b9d842ef7d27875eacecbbad71a9aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim=20and=20Mikel=20Lindsaar?= Date: Sat, 23 Jan 2010 21:50:36 +1100 Subject: Adding collector to ActionMailer --- actionmailer/lib/action_mailer/collector.rb | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 actionmailer/lib/action_mailer/collector.rb (limited to 'actionmailer/lib/action_mailer') diff --git a/actionmailer/lib/action_mailer/collector.rb b/actionmailer/lib/action_mailer/collector.rb new file mode 100644 index 0000000000..49c3f04bad --- /dev/null +++ b/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 \ No newline at end of file -- cgit v1.2.3