Sha256: cc993f8130669aef72e3810cd7223b6397ba5cf7977383a7a0f8971e1344d468
Contents?: true
Size: 1.61 KB
Versions: 23
Compression:
Stored size: 1.61 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: Mongoid::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
23 entries across 23 versions & 1 rubygems