Sha256: 0b787dafcdc275137d6e593dca59e3d4cf36734427b33912eee1409d141caaed

Contents?: true

Size: 888 Bytes

Versions: 181

Compression:

Stored size: 888 Bytes

Contents

# frozen_string_literal: true

require "abstract_controller/collector"
require "active_support/core_ext/hash/reverse_merge"
require "active_support/core_ext/array/extract_options"

module ActionMailer
  class Collector
    include AbstractController::Collector
    attr_reader :responses

    def initialize(context, &block)
      @context = context
      @responses = []
      @default_render = block
    end

    def any(*args, &block)
      options = args.extract_options!
      raise ArgumentError, "You have to supply at least one format" if args.empty?
      args.each { |type| send(type, options.dup, &block) }
    end
    alias :all :any

    def custom(mime, options = {})
      options.reverse_merge!(content_type: mime.to_s)
      @context.formats = [mime.to_sym]
      options[:body] = block_given? ? yield : @default_render.call
      @responses << options
    end
  end
end

Version data entries

181 entries across 176 versions & 13 rubygems

Version Path
actionmailer-8.0.0 lib/action_mailer/collector.rb
actionmailer-7.2.2 lib/action_mailer/collector.rb
actionmailer-7.1.5 lib/action_mailer/collector.rb
actionmailer-8.0.0.rc2 lib/action_mailer/collector.rb
actionmailer-7.2.1.2 lib/action_mailer/collector.rb
actionmailer-7.1.4.2 lib/action_mailer/collector.rb
actionmailer-7.0.8.6 lib/action_mailer/collector.rb
actionmailer-6.1.7.10 lib/action_mailer/collector.rb
actionmailer-8.0.0.rc1 lib/action_mailer/collector.rb
actionmailer-6.1.7.9 lib/action_mailer/collector.rb
actionmailer-7.2.1.1 lib/action_mailer/collector.rb
actionmailer-7.1.4.1 lib/action_mailer/collector.rb
actionmailer-7.0.8.5 lib/action_mailer/collector.rb
actionmailer-8.0.0.beta1 lib/action_mailer/collector.rb
omg-actionmailer-8.0.0.alpha9 lib/action_mailer/collector.rb
omg-actionmailer-8.0.0.alpha8 lib/action_mailer/collector.rb
omg-actionmailer-8.0.0.alpha7 lib/action_mailer/collector.rb
omg-actionmailer-8.0.0.alpha4 lib/action_mailer/collector.rb
omg-actionmailer-8.0.0.alpha3 lib/action_mailer/collector.rb
omg-actionmailer-8.0.0.alpha2 lib/action_mailer/collector.rb