Sha256: 99ea98eccd638150e624fe880199fd606c117e5d78624c9e389963eb68f1cd59

Contents?: true

Size: 1.1 KB

Versions: 8

Compression:

Stored size: 1.1 KB

Contents

require 'hanami/utils/basic_object'

module Hanami::Mailer
  # @since 0.5.0
  # @api private
  class Delivery < ::Hanami::Utils::BasicObject
    # @since 0.5.0
    # @api private
    def initialize(env, &blk)
      @env = env
      instance_eval(&blk)
    end

    # @since 0.5.0
    # @api private
    def to_config
      @config
    end

    # @since 0.5.0
    # @api private
    def test(*args)
      __setup_config(:test, *args)
    end

    private

    # @since 0.5.0
    # @api private
    def method_missing(m, *args)
      __setup_config(m, *args)
    end

    # @since 0.5.0
    # @api private
    def __setup_config(env, *args)
      if env.to_s == @env
        @config = args
      end
    end
  end


  # @since 0.5.0
  # @api private
  module Glue

    # @since 0.5.0
    # @api private
    def delivery(&blk)
      raise ArgumentError unless block_given?
      delivery_method(*Hanami::Mailer::Delivery.new(Hanami.env, &blk).to_config)
    end
  end

  Configuration.class_eval do
    include Glue
  end
end

# @since 0.5.0
# @api private
module Mailers
end

Hanami::Mailer.configure do
  namespace Mailers
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hanami-0.9.2 lib/hanami/mailer/glue.rb
hanami-0.9.1 lib/hanami/mailer/glue.rb
hanami-0.9.0 lib/hanami/mailer/glue.rb
hanami-0.8.0 lib/hanami/mailer/glue.rb
hanami-0.7.3 lib/hanami/mailer/glue.rb
hanami-0.7.2 lib/hanami/mailer/glue.rb
hanami-0.7.1 lib/hanami/mailer/glue.rb
hanami-0.7.0 lib/hanami/mailer/glue.rb