Module: ActionMailer::Callbacks::Methods
- Defined in:
- lib/actionmailer/callbacks/methods.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- CALLBACK_TYPES =
%w[before_create after_create before_deliver after_deliver]
- AROUND_METHODS =
%w[around_create around_deliver]
Class Method Summary collapse
Instance Method Summary collapse
- #create_with_create_callbacks!(*args) ⇒ Object
- #deliver_with_deliver_callbacks!(*args) ⇒ Object
- #run_around_create_method(&block) ⇒ Object
- #run_around_deliver_method(&block) ⇒ Object
Class Method Details
.included(base) ⇒ Object
13 14 15 16 17 |
# File 'lib/actionmailer/callbacks/methods.rb', line 13 def self.included(base) base.extend ClassMethods base.alias_method_chain :create!, :create_callbacks base.alias_method_chain :deliver!, :deliver_callbacks end |
Instance Method Details
#create_with_create_callbacks!(*args) ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/actionmailer/callbacks/methods.rb', line 62 def create_with_create_callbacks!(*args) @params = args run_around_create_method do run_before_create_callbacks create_without_create_callbacks!(*args) run_after_create_callbacks @mail end end |
#deliver_with_deliver_callbacks!(*args) ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'lib/actionmailer/callbacks/methods.rb', line 72 def deliver_with_deliver_callbacks!(*args) run_around_deliver_method do run_before_deliver_callbacks deliver_without_deliver_callbacks!(*args) run_after_deliver_callbacks @mail end end |
#run_around_create_method(&block) ⇒ Object
95 96 97 98 99 100 101 102 103 |
# File 'lib/actionmailer/callbacks/methods.rb', line 95 def run_around_create_method(&block) self.class.send('around_create_methods').each do |callback| if callback.should_run?(@params.first) send callback.name, &block return end end block.call end |
#run_around_deliver_method(&block) ⇒ Object
105 106 107 108 109 110 111 112 113 |
# File 'lib/actionmailer/callbacks/methods.rb', line 105 def run_around_deliver_method(&block) self.class.send('around_deliver_methods').each do |callback| if callback.should_run?(@params.first) send callback.name, &block return end end block.call end |