Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
sparkpost_rails (1.5.1)
sparkpost_rails (1.5.2)
rails (>= 4.0, < 5.3)

GEM
Expand Down
1 change: 1 addition & 0 deletions lib/sparkpost_rails.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require "sparkpost_rails/data_options"
require "sparkpost_rails/delivery_method"
require "sparkpost_rails/exceptions"
require "sparkpost_rails/message_data"
require "sparkpost_rails/railtie"

module SparkPostRails
Expand Down
4 changes: 3 additions & 1 deletion lib/sparkpost_rails/data_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ def mail(headers={}, &block)
sparkpost_data = headers.delete(:sparkpost_data)
sparkpost_data ||= {}
super(headers, &block).tap do |message|
message.singleton_class.class_eval { attr_accessor "sparkpost_data" }
unless message.respond_to?(:sparkpost_data=)
message.singleton_class.class_eval { attr_accessor "sparkpost_data" }
end
message.sparkpost_data = sparkpost_data
end
end
Expand Down
15 changes: 15 additions & 0 deletions lib/sparkpost_rails/message_data.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module SparkPostRails
module MessageData

def self.included(base)
base.class_eval do
attr_writer :sparkpost_data

def sparkpost_data
@sparkpost_data ||= {}
end
end
end

end
end
6 changes: 6 additions & 0 deletions lib/sparkpost_rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@ class Railtie < Rails::Railtie
ActionMailer::Base.send :include, SparkPostRails::DataOptions
end
end

initializer 'sparkpost_rails.include_message_data' do
ActiveSupport.on_load :action_mailer do
Mail::Message.send :include, SparkPostRails::MessageData
end
end
end
end
2 changes: 1 addition & 1 deletion lib/sparkpost_rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module SparkPostRails
VERSION = "1.5.1"
VERSION = "1.5.2"
end

1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

config.before(:all) do
ActionMailer::Base.send :include, SparkPostRails::DataOptions
Mail::Message.send :include, SparkPostRails::MessageData
end

config.before(:each) do |example|
Expand Down