mail
mail copied to clipboard
Lazy-load fields and elements
Even though there are autoload rules specified for (nearly) all field classes, these are eager-loaded by require 'mail'
. This defeats some of the purpose with using autoload.
I have used this little script to see how many files are included:
module Kernel
alias_method :old_require, :require
def require(file)
loaded = old_require(file)
puts file if loaded
loaded
end
end
$LOAD_PATH.unshift "#{__dir__}/lib"
require 'mail'
This PR removes the explicit loading files in lib/mail/fields
and lib/mail/elements
. This reduces the number files initially required from 95 to 42. The loading of these files is postponed until this gem is actually used to send a mail.
The performance impact of this is tiny, but if you use many gems, it all adds up.