Module: CoreSystemConfiguration

Extended by:
ActiveSupport::Concern
Defined in:
lib/app/models/concerns/core_system_configuration.rb

Overview

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.

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

EMAIL_PROVIDER_SMTP_TYPE =
'smtp'.freeze
EMAIL_PROVIDER_SES_TYPE =
'ses'.freeze
ALL_EMAIL_PROVIDER_TYPES =
[EMAIL_PROVIDER_SMTP_TYPE, EMAIL_PROVIDER_SES_TYPE].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/app/models/concerns/core_system_configuration.rb', line 23

def self.included(base)
  base.class_eval do
    attr_accessor :configuration

    #
    # Fields
    #
    field :environment, type: String, default: 'test'
    field :fips_mode, type: Boolean, default: false
    field :fav_icon_path, { type: String, default: '/favicon.ico' }
    field :stack_logo_path, { type: String, default: 'ui-company-logo.png' }
    field :primary_stylesheet, { type: String, default: 'app47' }
    field :short_cache, { type: Integer, default: 1 }
    field :medium_cache, { type: Integer, default: 5 }
    field :long_cache, { type: Integer, default: 15 }
    field :stack_email_provider, type: String, default: EMAIL_PROVIDER_SMTP_TYPE
    # URLs
    field :base_url, type: String
    field :cdn_url, type: String
    field :asset_cdn_url, type: String
    # Time Zone Support
    field :default_time_zone, type: String, default: 'US/Eastern'
    # TTLs
    field :user_model_audit_log_ttl, type: Integer, default: 365
    #
    # Validations
    #
    validates :environment, presence: true, uniqueness: true
    validates :default_time_zone, presence: true
    validates :stack_email_provider, inclusion: { in: ALL_EMAIL_PROVIDER_TYPES }
  end
  base.extend ClassMethods
end

Instance Method Details

#long_cache_timeObject



104
105
106
# File 'lib/app/models/concerns/core_system_configuration.rb', line 104

def long_cache_time
  long_cache.minutes
end

#medium_cache_timeObject



100
101
102
# File 'lib/app/models/concerns/core_system_configuration.rb', line 100

def medium_cache_time
  medium_cache.minutes
end

#short_cache_timeObject

Cache times in minutes



96
97
98
# File 'lib/app/models/concerns/core_system_configuration.rb', line 96

def short_cache_time
  short_cache.minutes
end

#stack_ses_provider?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/app/models/concerns/core_system_configuration.rb', line 85

def stack_ses_provider?
  EMAIL_PROVIDER_SES_TYPE.eql?(stack_email_provider)
end

#stack_smtp_provider?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/app/models/concerns/core_system_configuration.rb', line 89

def stack_smtp_provider?
  EMAIL_PROVIDER_SMTP_TYPE.eql?(stack_email_provider)
end