Module: SwitchboardConfiguration

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

Overview

Switchboard configuration, both the fields and methods needed to determine configuration

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Switchboard configuration



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/app/models/concerns/switchboard_configuration.rb', line 11

def self.included(base)
  base.class_eval do
    # Switchboard
    field :switchboard_base_url, type: String, default: 'https://switchboard.app47.com'
    field :switchboard_stack_id, type: String
    field :switchboard_stack_api_token, type: String
    field :switchboard_last_sync_at, type: Time
    #
    # Validations
    #
    validates :switchboard_base_url, url: true
  end
end

Instance Method Details

#secure_fieldsObject

Make sure the password doesn’t get blanked out on an update



28
29
30
# File 'lib/app/models/concerns/switchboard_configuration.rb', line 28

def secure_fields
  super + %i[switchboard_stack_api_token]
end

#switchboard_configured?Boolean

Public: Determine if switchboard is configured

Examples

switchboard_configured?
# => true || false

Returns:

  • (Boolean)


40
41
42
# File 'lib/app/models/concerns/switchboard_configuration.rb', line 40

def switchboard_configured?
  [switchboard_base_url.present?, switchboard_stack_api_token.present?, switchboard_stack_id.present?].all?
end