Class: ActionMailer::Callbacks::Callback

Inherits:
Object
  • Object
show all
Defined in:
lib/actionmailer/callbacks/callback.rb

Overview

this object stores the callback data

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(callback_name, opts = {}) ⇒ Callback

Returns a new instance of Callback.



7
8
9
10
11
# File 'lib/actionmailer/callbacks/callback.rb', line 7

def initialize(callback_name, opts={})
  @name   = callback_name
  @only   = Array.wrap(opts[:only]).map(&:to_s)
  @except = Array.wrap(opts[:except]).map(&:to_s)
end

Instance Attribute Details

#exceptObject

Returns the value of attribute except.



5
6
7
# File 'lib/actionmailer/callbacks/callback.rb', line 5

def except
  @except
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/actionmailer/callbacks/callback.rb', line 5

def name
  @name
end

#onlyObject

Returns the value of attribute only.



5
6
7
# File 'lib/actionmailer/callbacks/callback.rb', line 5

def only
  @only
end

Instance Method Details

#should_run?(mailer_method) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
# File 'lib/actionmailer/callbacks/callback.rb', line 13

def should_run?(mailer_method)
  if @only.present?
    @only.include?(mailer_method.to_s)
  else
    !@except.include?(mailer_method.to_s)
  end
end