Sha256: dc49c23f78f9bd4c579a9873a42935a4eb0f782157222b24977eb96d15400ef4

Contents?: true

Size: 798 Bytes

Versions: 18

Compression:

Stored size: 798 Bytes

Contents

# frozen_string_literal: true

#
# The Base Account
#
module CoreAccount
  extend ActiveSupport::Concern

  def self.included(base)
    base.class_eval do
      #
      # Fields
      #
      field :name, type: String
      #
      # Relationships
      #
      has_many :notifications, dependent: :delete do
        def emails
          where(_type: 'EmailNotification')
        end

        def slacks
          where(_type: 'SlackNotification')
        end

        def sms
          where(_type: 'SmsNotification')
        end
      end
      has_many :templates, dependent: :delete
      embeds_one :smtp_configuration
    end
  end

  #
  # Return or build the smtp configuration for the account
  #
  def fetch_smtp_configuration
    smtp_configuration || build_smtp_configuration
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
web47core-0.6.3 lib/app/models/concerns/core_account.rb
web47core-0.6.2 lib/app/models/concerns/core_account.rb
web47core-0.6.1 lib/app/models/concerns/core_account.rb
web47core-0.6.0 lib/app/models/concerns/core_account.rb
web47core-0.5.5 lib/app/models/concerns/core_account.rb
web47core-0.5.4 lib/app/models/concerns/core_account.rb
web47core-0.5.3 lib/app/models/concerns/core_account.rb
web47core-0.5.2 lib/app/models/concerns/core_account.rb
web47core-0.4.5 lib/app/models/concerns/core_account.rb
web47core-0.4.4 lib/app/models/concerns/core_account.rb
web47core-0.4.3 lib/app/models/concerns/core_account.rb
web47core-0.4.2 lib/app/models/concerns/core_account.rb
web47core-0.4.0 lib/app/models/concerns/core_account.rb
web47core-0.3.4 lib/app/models/concerns/core_account.rb
web47core-0.3.3 lib/app/models/concerns/core_account.rb
web47core-0.3.2 lib/app/models/concerns/core_account.rb
web47core-0.3.1 lib/app/models/concerns/core_account.rb
web47core-0.3.0 lib/app/models/concerns/core_account.rb