diff options
Diffstat (limited to 'actionmailer/lib/action_mailer/collector.rb')
-rw-r--r-- | actionmailer/lib/action_mailer/collector.rb | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/actionmailer/lib/action_mailer/collector.rb b/actionmailer/lib/action_mailer/collector.rb index 49c3f04bad..0891b6f123 100644 --- a/actionmailer/lib/action_mailer/collector.rb +++ b/actionmailer/lib/action_mailer/collector.rb @@ -1,23 +1,29 @@ require 'abstract_controller/collector' +require 'active_support/core_ext/hash/reverse_merge' +require 'active_support/core_ext/array/extract_options' module ActionMailer #:nodoc: - class Collector - include AbstractController::Collector - - attr_accessor :responses + attr_reader :responses - def initialize(context, options, &block) - @default_options = options - @default_render = block - @default_formats = context.formats + def initialize(context, &block) @context = context @responses = [] + @default_render = block + @default_formats = context.formats + end + + # TODO Test me + def any(*args, &block) + options = args.extract_options! + raise "You have to supply at least one format" if args.empty? + args.each { |type| send(type, options, &block) } end + alias :all :any def custom(mime, options={}, &block) - options = @default_options.merge(:content_type => mime.to_s).merge(options) + options.reverse_merge!(:content_type => mime.to_s) @context.formats = [mime.to_sym] options[:body] = if block block.call @@ -27,6 +33,5 @@ module ActionMailer #:nodoc: @responses << options @context.formats = @default_formats end - end end
\ No newline at end of file |