aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/lib
diff options
context:
space:
mode:
authorJosé Valim and Mikel Lindsaar <pair@programming.com>2010-01-23 21:50:36 +1100
committerJosé Valim and Mikel Lindsaar <pair@programming.com>2010-01-23 21:50:36 +1100
commit5a19d24892b9d842ef7d27875eacecbbad71a9aa (patch)
tree2549d85612b0626e9ce6641fc816aa965948e752 /actionmailer/lib
parentc6b16260fe3d1435848e78415bd0b40c10ad7424 (diff)
downloadrails-5a19d24892b9d842ef7d27875eacecbbad71a9aa.tar.gz
rails-5a19d24892b9d842ef7d27875eacecbbad71a9aa.tar.bz2
rails-5a19d24892b9d842ef7d27875eacecbbad71a9aa.zip
Adding collector to ActionMailer
Diffstat (limited to 'actionmailer/lib')
-rw-r--r--actionmailer/lib/action_mailer/collector.rb32
1 files changed, 32 insertions, 0 deletions
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