Open Mange opened 9 years ago
Pending your decision on this issue I decided not to use Automatic
in our codebase. However, this raised some concerns for me, like: how do I make sure everybody uses Roadie
for all the emails?
I think this is something all users of roadie with larger teams could run into, so I thought it might be interesting to share the custom Rubocop linter that I wrote:
module RuboCop
module Cop
module HackerOne
class NoMailMethod < Cop
MSG = 'Use `roadie_mail` instead of `mail`.'
def on_send(node)
return unless command?(:mail, node)
add_offense(node, :selector)
end
end
end
end
end
You can include this in your rubocop.yml
like this:
require: ./lib/rubocop/no_mail_method
Also: without the Automatic
class I had to monkey patch devise
a little to make sure the devise email-css was also inlined:
Devise::Mailer.class_eval do
include Roadie::Rails::Mailer
protected
def devise_mail(record, action, opts = {})
initialize_from_record(record)
roadie_mail headers_for(action, opts)
end
private
def roadie_options
super unless Rails.env.test?
end
end
I'm not really happy with that monkey patching, so I'm interested if you have other suggestions to solve this (from what I read in the roadie issues you're not a big monkey-patch fan ;-)).
Thank you for the input. I'll consider these use cases when I'm designing the replacement.
What license would you put your code under? Would you mind seeing it added to the README?
I don't mind! MIT I guess!
Deprecate
Automatic
in favor of something better.Problems with
Automatic
:roadie
, and this would be hard to debug without knowledge of howAutomatic
attaches itself.Things I'd like to keep:
roadie
path, but still not do any expensive inlining when running tests.disabled
configuration parameter?roadie
disabled, then again with it enabled?Since we're on semver, we cannot just drop
Automatic
just like that (and for good reason! People seem to actually use it.). I'll instead introduce a new module, which will be the successor, and then deprecate theAutomatic
module. We can then later drop it when we bump the next major release.