Sha256: 11f28078c786621548d7e2b60309bca094b00fe9d3be9519b4589c89a8160a5c

Contents?: true

Size: 1.25 KB

Versions: 14

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

#
# The System configuration. Various configuration items that can be updated/defined at run time
#
# Use of this class allows you to simply ask for the configuration parameter directly without
# first having to get an instance of it.
#
# SystemConfiguration.queue_impl #=> 'RedisQueue'
#
# This method only is allowed for accessors, you should NEVER set values on the SystemConfiguration
# unless you are updating via the Admin or Stack UI, or during testing to setup a specific configuration
# for that.
#
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

14 entries across 14 versions & 1 rubygems

Version Path
web47core-0.1.11 lib/app/models/concerns/core_account.rb
web47core-0.1.10 lib/app/models/concerns/core_account.rb
web47core-0.1.9 lib/app/models/concerns/core_account.rb
web47core-0.1.8 lib/app/models/concerns/core_account.rb
web47core-0.1.7 lib/app/models/concerns/core_account.rb
web47core-0.1.6 lib/app/models/concerns/core_account.rb
web47core-0.1.5 lib/app/models/concerns/core_account.rb
web47core-0.1.4 lib/app/models/concerns/core_account.rb
web47core-0.1.3 lib/app/models/concerns/core_account.rb
web47core-0.1.2 lib/app/models/concerns/core_account.rb
web47core-0.1.1 lib/app/models/concerns/core_account.rb
web47core-0.1.0 lib/app/models/concerns/core_account.rb
web47core-0.0.10 lib/app/models/concerns/core_account.rb
web47core-0.0.9 lib/app/models/concerns/core_account.rb