Module: MailJack
- Defined in:
- lib/mail_jack.rb,
lib/mail_jack/config.rb,
lib/mail_jack/mailer.rb,
lib/mail_jack/version.rb,
lib/mail_jack/interceptor.rb,
lib/mail_jack/params_decoder.rb
Defined Under Namespace
Modules: Mailer Classes: Config, Interceptor, ParamsDecoder
Constant Summary collapse
- VERSION =
The version of the gem
'0.2.5'.freeze
Class Method Summary collapse
- .config {|@@config| ... } ⇒ Object
- .configured? ⇒ Boolean
-
.fetch_attributes(mailer) ⇒ Object
Fetch attributes gets the dynamically defined attributes off the object passed in, the object is ActionMailer::Base instance.
- .trackables ⇒ Object
Class Method Details
.config {|@@config| ... } ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/mail_jack.rb', line 55 def self.config # return configuration if already configured return @@config if defined?(@@config) and @@config.kind_of?(Config) raise ArgumentError, "you must configure MailJack to use it. call MailJack.config{|config| ...} from an initializer" unless block_given? # yield configuration @@config = Config.new yield @@config # dynamically define the accessors onto Mail::Message # so we can assign them later in the Interceptor Mail::Message.class_eval do attr_accessor *@@config.trackables.keys if @@config.trackables end # include the module that decorates(ie monkey patches) # the Mail::Message#mail method @@config.mailers.each do |mailer| mailer.to_s.classify.constantize.send(:include, Mailer) end # register the interceptor Mail.register_interceptor(MailJack::Interceptor) @@config.configured = true end |
.configured? ⇒ Boolean
84 85 86 |
# File 'lib/mail_jack.rb', line 84 def self.configured? defined?(@@config) and @@config.configured? end |
.fetch_attributes(mailer) ⇒ Object
Fetch attributes gets the dynamically defined attributes off the object passed in, the object is ActionMailer::Base instance
90 91 92 93 94 95 96 |
# File 'lib/mail_jack.rb', line 90 def self.fetch_attributes(mailer) map = {} self.trackables.each do |attribute, proc| map[attribute] = proc.call(mailer) end return map end |
.trackables ⇒ Object
98 99 100 |
# File 'lib/mail_jack.rb', line 98 def self.trackables @@config.trackables end |