Class: Setting
- Inherits:
-
RailsSettings::Base
- Object
- RailsSettings::Base
- Setting
- Includes:
- Models::Auditable
- Defined in:
- app/models/setting.rb
Overview
== Schema Information
Table name: settings
Database name: primary
id :bigint not null, primary key
value :text
var :string not null
created_at :datetime not null
updated_at :datetime not null
Indexes
index_settings_on_var (var) UNIQUE
Defined Under Namespace
Classes: SettingPermission
Constant Summary
Constants included from Models::Auditable
Models::Auditable::ALWAYS_IGNORED
Class Method Summary collapse
-
.ai_vision ⇒ ActiveRecord::Relation<Setting>
A relation of Settings that are ai vision.
-
.brand_voice ⇒ ActiveRecord::Relation<Setting>
A relation of Settings that are brand voice.
-
.call_transcription ⇒ ActiveRecord::Relation<Setting>
A relation of Settings that are call transcription.
-
.ip_in_switchvox_whitelist?(remote_ip) ⇒ Boolean
Check if an IP matches the whitelist (supports CIDR) Returns true if whitelist is empty (no IP restriction configured).
-
.permission_for(key) ⇒ Object
Helper method to create a permission check object.
-
.phone_system ⇒ ActiveRecord::Relation<Setting>
A relation of Settings that are phone system.
- .ransackable_associations(_auth_object = nil) ⇒ Object
-
.ransackable_attributes(_auth_object = nil) ⇒ Object
============================================================================= Ransack & CanCanCan Configuration =============================================================================.
-
.transcription ⇒ ActiveRecord::Relation<Setting>
A relation of Settings that are transcription.
-
.validate_switchvox_webhook_ips(ip_list) ⇒ Object
Validate IP/CIDR format when setting switchvox_webhook_ips Returns array of invalid entries, empty if all valid.
-
.video_processing ⇒ ActiveRecord::Relation<Setting>
A relation of Settings that are video processing.
Methods included from Models::Auditable
#all_skipped_columns, #audit_reference_data, #creator, #should_not_save_version, #stamp_record, #updater
Class Method Details
.ai_vision ⇒ ActiveRecord::Relation<Setting>
A relation of Settings that are ai vision. Active Record Scope
78 79 80 81 82 |
# File 'app/models/setting.rb', line 78 scope :ai_vision do field :ai_vision_model, type: :string field :ai_vision_max_tokens, type: :integer field :ai_vision_prompt, type: :string end |
.brand_voice ⇒ ActiveRecord::Relation<Setting>
A relation of Settings that are brand voice. Active Record Scope
87 88 89 90 91 92 |
# File 'app/models/setting.rb', line 87 scope :brand_voice do field :brand_voice_guidelines, type: :string field :brand_voice_examples, type: :string field :brand_voice_phrases_to_use, type: :array field :brand_voice_phrases_to_avoid, type: :array end |
.call_transcription ⇒ ActiveRecord::Relation<Setting>
A relation of Settings that are call transcription. Active Record Scope
56 57 58 59 60 61 62 63 64 |
# File 'app/models/setting.rb', line 56 scope :call_transcription do field :call_transcription_lemur_system_prompt, type: :string field :call_transcription_lemur_analysis_prompt, type: :string field :call_transcription_lemur_model, type: :string field :call_transcription_lemur_max_tokens, type: :integer field :call_transcription_lemur_temperature, type: :float field :call_transcription_speech_model, type: :string field :call_transcription_keyterms, type: :array end |
.ip_in_switchvox_whitelist?(remote_ip) ⇒ Boolean
Check if an IP matches the whitelist (supports CIDR)
Returns true if whitelist is empty (no IP restriction configured)
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'app/models/setting.rb', line 118 def self.ip_in_switchvox_whitelist?(remote_ip) whitelist = Array(switchvox_webhook_ips).reject(&:blank?) # Empty whitelist = no IP restriction, allow all return true if whitelist.empty? return false if remote_ip.blank? begin remote = IPAddr.new(remote_ip) whitelist.any? do |allowed| IPAddr.new(allowed.to_s.strip).include?(remote) rescue IPAddr::InvalidAddressError false end rescue IPAddr::InvalidAddressError false end end |
.permission_for(key) ⇒ Object
Helper method to create a permission check object
160 161 162 |
# File 'app/models/setting.rb', line 160 def self.(key) SettingPermission.new(key) end |
.phone_system ⇒ ActiveRecord::Relation<Setting>
A relation of Settings that are phone system. Active Record Scope
69 70 71 72 73 |
# File 'app/models/setting.rb', line 69 scope :phone_system do field :call_recording_twilio_enabled, type: :boolean field :call_recording_twilio_trunk_id, type: :string field :switchvox_webhook_ips, type: :array end |
.ransackable_associations(_auth_object = nil) ⇒ Object
145 146 147 |
# File 'app/models/setting.rb', line 145 def self.ransackable_associations(_auth_object = nil) [] end |
.ransackable_attributes(_auth_object = nil) ⇒ Object
=============================================================================
Ransack & CanCanCan Configuration
141 142 143 |
# File 'app/models/setting.rb', line 141 def self.ransackable_attributes(_auth_object = nil) %w[created_at id updated_at value var] end |
.transcription ⇒ ActiveRecord::Relation<Setting>
A relation of Settings that are transcription. Active Record Scope
25 26 27 |
# File 'app/models/setting.rb', line 25 scope :transcription do field :transcription_spelling_corrections, type: :hash end |
.validate_switchvox_webhook_ips(ip_list) ⇒ Object
Validate IP/CIDR format when setting switchvox_webhook_ips
Returns array of invalid entries, empty if all valid
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'app/models/setting.rb', line 100 def self.validate_switchvox_webhook_ips(ip_list) return [] if ip_list.blank? invalid = [] Array(ip_list).each do |ip| next if ip.blank? begin IPAddr.new(ip.to_s.strip) rescue IPAddr::InvalidAddressError, IPAddr::AddressFamilyError invalid << ip end end invalid end |
.video_processing ⇒ ActiveRecord::Relation<Setting>
A relation of Settings that are video processing. Active Record Scope
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/models/setting.rb', line 32 scope :video_processing do field :video_processing_transcription_keyterms_prompt, type: :array field :video_processing_transcription_spelling_corrections, type: :hash field :video_processing_seo_prompt, type: :string field :video_processing_seo_model, type: :string field :video_processing_seo_max_tokens, type: :integer field :video_processing_seo_temperature, type: :float field :video_processing_paragraph_system_prompt, type: :string field :video_processing_paragraph_user_prompt, type: :string field :video_processing_paragraph_model, type: :string field :video_processing_paragraph_max_tokens, type: :integer field :video_processing_paragraph_temperature, type: :float field :video_processing_polish_system_prompt, type: :string field :video_processing_polish_user_prompt, type: :string field :video_processing_translate_system_prompt, type: :string field :video_processing_translate_user_prompt, type: :string field :video_processing_llm_model, type: :string field :video_processing_llm_max_tokens, type: :integer field :video_processing_llm_temperature, type: :float end |