Sha256: f2891296fa77522ad0cf86e91680399becbe789561192d0d12db0cde3bbf9ad8

Contents?: true

Size: 901 Bytes

Versions: 3

Compression:

Stored size: 901 Bytes

Contents

module SendGrid
  autoload :ApiHeader, 'send_grid/api_header'
  autoload :MailInterceptor, 'send_grid/mail_interceptor'
  autoload :VERSION, 'send_grid/version'

  def self.included(base)
    base.class_eval do
      include InstanceMethods
      delegate :substitute, :uniq_args, :category, :add_filter_setting, :to => :sendgrid_header
      alias_method_chain :mail, :sendgrid
      alias_method :sendgrid_header, :send_grid_header
    end
  end

  module InstanceMethods
    def send_grid_header
      @send_grid_header ||= SendGrid::ApiHeader.new
    end

    def mail_with_sendgrid(headers={}, &block)
      mail_without_sendgrid(headers, &block).tap do |message|
        message.instance_variable_set :@sendgrid_header, sendgrid_header
      end
    end

    def open_tracking(enabled = true)
      add_filter_setting(:opentrack, :enabled, enabled ? 1 : 0) unless enabled.nil?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sendgrid-rails-2.0.2 lib/send_grid.rb
sendgrid-rails-2.0.1 lib/send_grid.rb
sendgrid-rails-2.0 lib/send_grid.rb