Module: ActionMailer::Previews::ClassMethods

Defined in:
lib/action_mailer/preview.rb

Instance Method Summary collapse

Instance Method Details

#preview_pathObject



45
46
47
48
49
50
51
# File 'lib/action_mailer/preview.rb', line 45

def preview_path
  ActionMailer.deprecator.warn(<<-MSG.squish)
    Using preview_path option is deprecated and will be removed in Rails 7.2.
    Please use preview_paths instead.
  MSG
  self.preview_paths.first
end

#preview_path=(value) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/action_mailer/preview.rb', line 37

def preview_path=(value)
  ActionMailer.deprecator.warn(<<-MSG.squish)
    Using preview_path= option is deprecated and will be removed in Rails 7.2.
    Please use preview_paths= instead.
  MSG
  self.preview_paths << value
end

#register_preview_interceptor(interceptor) ⇒ Object

Register an Interceptor which will be called before mail is previewed. Either a class or a string can be passed in as the Interceptor. If a string is passed in it will be constantized.



66
67
68
69
70
71
72
# File 'lib/action_mailer/preview.rb', line 66

def register_preview_interceptor(interceptor)
  preview_interceptor = interceptor_class_for(interceptor)

  unless preview_interceptors.include?(preview_interceptor)
    preview_interceptors << preview_interceptor
  end
end

#register_preview_interceptors(*interceptors) ⇒ Object

Register one or more Interceptors which will be called before mail is previewed.



54
55
56
# File 'lib/action_mailer/preview.rb', line 54

def register_preview_interceptors(*interceptors)
  interceptors.flatten.compact.each { |interceptor| register_preview_interceptor(interceptor) }
end

#unregister_preview_interceptor(interceptor) ⇒ Object

Unregister a previously registered Interceptor. Either a class or a string can be passed in as the Interceptor. If a string is passed in it will be constantized.



77
78
79
# File 'lib/action_mailer/preview.rb', line 77

def unregister_preview_interceptor(interceptor)
  preview_interceptors.delete(interceptor_class_for(interceptor))
end

#unregister_preview_interceptors(*interceptors) ⇒ Object

Unregister one or more previously registered Interceptors.



59
60
61
# File 'lib/action_mailer/preview.rb', line 59

def unregister_preview_interceptors(*interceptors)
  interceptors.flatten.compact.each { |interceptor| unregister_preview_interceptor(interceptor) }
end