Module: CoreSmtpConfiguration

Extended by:
ActiveSupport::Concern
Defined in:
lib/app/models/concerns/core_smtp_configuration.rb

Overview

SMTP Configuration

Defined Under Namespace

Modules: SmtpClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/app/models/concerns/core_smtp_configuration.rb', line 9

def self.included(base)
  base.class_eval do
    #
    # Fields
    #
    field :default_email, type: String, default: '[email protected]'
    field :support_email, type: String, default: '[email protected]'
    field :smtp_name, type: String
    field :smtp_address, type: String
    field :smtp_domain, type: String
    field :smtp_port, type: Integer, default: 587
    field :smtp_user_name, type: String
    field :smtp_password, type: String
    field :smtp_enable_starttls_auto, type: Mongoid::Boolean, default: false
    field :mailgun_api_key, type: String
    field :email_notification_ttl, type: Integer, default: 180
  end
  base.extend SmtpClassMethods
end

Instance Method Details

#mail_gun_configured?Boolean

Determine if mailgun is configured

Returns:

  • (Boolean)


62
63
64
# File 'lib/app/models/concerns/core_smtp_configuration.rb', line 62

def mail_gun_configured?
  smtp_configured? && mailgun_api_key.present?
end

#secure_fieldsObject

Make sure the password doesn’t get blanked out on an update



48
49
50
# File 'lib/app/models/concerns/core_smtp_configuration.rb', line 48

def secure_fields
  super + %i[smtp_password mailgun_api_key]
end

#smtp_configured?Boolean

Determine if SMTP is configured

Returns:

  • (Boolean)


55
56
57
# File 'lib/app/models/concerns/core_smtp_configuration.rb', line 55

def smtp_configured?
  smtp_name.present? && smtp_address.present? && smtp_domain.present?
end