Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

I had to remove these lines since they were actually breaking the desired functionality. Can you review and merge? #8

Merged
merged 2 commits into from

4 participants

@akenger

These lines are actually conflicting with the previous statement that merges the class level defaults with the method arguments.

akenger added some commits
@akenger akenger Removed unnecessary lines
These lines are actually conflicting with the previous statement that merges the class level defaults with the method arguments.
24ec6a2
@akenger akenger More issues with unique_args
The first lines were removed as they were redundant but didn't default args to a hash.

In the event that the line is not called from a mail method at all, we default in the json builder so that the code runs.

The behavior is now as intended.  Args can be set globally or at method level.  At method will override global.
238103c
@jhecking

:+1: for merging this PR! Is this project still under active development?

@inspire22

Ping!

@stephenb stephenb merged commit 3b7767c into stephenb:master
@stephenb
Owner

Sorry for delay guys... so busy :(

@inspire22

Awesome, thanks! :) Ya push an updated gem? Don't work too hard http://zenhabits.net/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 16, 2012
  1. @akenger

    Removed unnecessary lines

    akenger authored
    These lines are actually conflicting with the previous statement that merges the class level defaults with the method arguments.
Commits on Dec 17, 2012
  1. @akenger

    More issues with unique_args

    akenger authored
    The first lines were removed as they were redundant but didn't default args to a hash.
    
    In the event that the line is not called from a mail method at all, we default in the json builder so that the code runs.
    
    The behavior is now as intended.  Args can be set globally or at method level.  At method will override global.
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 10 deletions.
  1. +3 −10 lib/sendgrid.rb
View
13 lib/sendgrid.rb
@@ -154,11 +154,6 @@ def sendgrid_ganalytics_options(options)
options.each { |option| @ganalytics_options << option if VALID_GANALYTICS_OPTIONS.include?(option[0].to_sym) }
end
- # Call within mailer method to set unique args for this email.
- def sendgrid_unique_args(args)
- @sg_unique_args = args
- end
-
# only override the appropriate methods for the current ActionMailer version
if ActionMailer::Base.respond_to?(:mail)
@@ -201,6 +196,9 @@ def create!(method_name, *parameters)
def sendgrid_json_headers(mail)
header_opts = {}
+ #if not called within the mailer method, this will be nil so we default to empty hash
+ @sg_unique_args = @sg_unique_args || {}
+
# set the unique arguments
if @sg_unique_args || self.class.default_sg_unique_args
unique_args = self.class.default_sg_unique_args || {}
@@ -245,11 +243,6 @@ def sendgrid_json_headers(mail)
header_opts[:filters] = filters_hash_from_options(enabled_opts, @sg_disabled_options)
end
- # Set unique_args
- if @sg_unique_args && !@sg_unique_args.empty?
- header_opts[:unique_args] = @sg_unique_args
- end
-
header_opts.to_json.gsub(/(["\]}])([,:])(["\[{])/, '\\1\\2 \\3')
end
Something went wrong with that request. Please try again.