Method: CoreAccount.included

Defined in:
lib/app/models/concerns/core_account.rb

.included(base) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/app/models/concerns/core_account.rb', line 9

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