Sha256: d0c0eabcf8cec8b94c8995e1180f14429a2c7ae3c1dde80e52cffb2e0894ebe2
Contents?: true
Size: 1.6 KB
Versions: 10
Compression:
Stored size: 1.6 KB
Contents
# frozen_string_literal: true # # SMTP Configuration # module CoreSmtpConfiguration extend ActiveSupport::Concern def self.included(base) base.class_eval do # # Fields # field :default_email, type: String, default: 'support@app47.com' field :support_email, type: String, default: 'support@app47.com' 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: Boolean, default: false field :mailgun_api_key, type: String field :email_notification_ttl, type: Integer, default: 180 end base.extend SmtpClassMethods end # # Class methods for smtp configuration # module SmtpClassMethods def smtp_configuration output = {} config = configuration fields = %w[name address domain port user_name password enable_starttls_auto] fields.each do |field| field_name = "smtp_#{field}".to_sym output[field.to_sym] = config.send(field_name) end output end end # # Make sure the password doesn't get blanked out on an update # def secure_fields super + %i[smtp_password mailgun_api_key] end # # Determine if SMTP is configured # def smtp_configured? smtp_name.present? && smtp_address.present? && smtp_domain.present? end # # Determine if mailgun is configured # def mail_gun_configured? smtp_configured? && mailgun_api_key.present? end end
Version data entries
10 entries across 10 versions & 1 rubygems