Class: AppMode
- Inherits:
-
Object
- Object
- AppMode
- Defined in:
- app/models/app_mode.rb
Constant Summary collapse
- PAYROLL_MODE =
'payroll'- EDI_MODE =
'edi'- AI_PLATFORM_MODE =
'ai_platform'- PAYROLL_MODE_APP_ID =
1- EDI_MODE_APP_ID =
2- AI_PLATFORM_MODE_APP_ID =
3- ACCEPTABLE_MODES =
[PAYROLL_MODE, EDI_MODE, AI_PLATFORM_MODE].freeze
Instance Attribute Summary collapse
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
Class Method Summary collapse
Instance Method Summary collapse
- #agreement_file_path ⇒ Object
- #agreement_path ⇒ Object
- #agreement_type ⇒ Object
- #application_id ⇒ Object
- #can_register? ⇒ Boolean
- #company_details_path ⇒ Object
- #company_details_present?(company:) ⇒ Boolean
-
#initialize(mode) ⇒ AppMode
constructor
A new instance of AppMode.
- #onboardable? ⇒ Boolean
- #permission_groups_codes ⇒ Object
- #software_name ⇒ Object
- #supports_partner_by_company? ⇒ Boolean
- #system_record_home_path ⇒ Object
- #system_user_navigation_configuration ⇒ Object
- #system_user_navigation_configuration_id ⇒ Object
- #user_navigation_configuration_id ⇒ Object
- #web_uri ⇒ Object
Constructor Details
#initialize(mode) ⇒ AppMode
Returns a new instance of AppMode.
44 45 46 47 48 |
# File 'app/models/app_mode.rb', line 44 def initialize(mode) raise ArgumentError, "Invalid mode: #{mode}" unless ACCEPTABLE_MODES.include?(mode) @mode = mode end |
Instance Attribute Details
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
42 43 44 |
# File 'app/models/app_mode.rb', line 42 def mode @mode end |
Class Method Details
.ai_platform ⇒ Object
37 38 39 |
# File 'app/models/app_mode.rb', line 37 def ai_platform AppMode.new(AI_PLATFORM_MODE) end |
.from_referer_host(host_name) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/models/app_mode.rb', line 15 def from_referer_host(host_name) if ['omni.edi2xml.com', 'app.paiehub.ca', 'dev.paiehub.ca'].include?(host_name) AppMode.new(PAYROLL_MODE) elsif ['app.edi2xml.com', 'devapp.edi2xml.com'].include?(host_name) AppMode.new(EDI_MODE) elsif ['askelixir.ai', 'ai.edi2xml.com', 'dev.askelixir.ai'].include?(host_name) AppMode.new(AI_PLATFORM_MODE) elsif Rails.env.local? AppMode.new(Rails.application.config.default_app_mode) else AppMode.new(PAYROLL_MODE) end end |
.payroll ⇒ Object
29 30 31 |
# File 'app/models/app_mode.rb', line 29 def payroll AppMode.new(PAYROLL_MODE) end |
Instance Method Details
#agreement_file_path ⇒ Object
159 160 161 162 163 164 165 166 167 |
# File 'app/models/app_mode.rb', line 159 def agreement_file_path if payroll? Parameter.payroll_agreement_path elsif edi? Parameter.edi_agreement_path elsif ai_platform? Parameter.ai_platform_agreement_path end end |
#agreement_path ⇒ Object
129 130 131 132 133 134 135 136 137 |
# File 'app/models/app_mode.rb', line 129 def agreement_path if payroll? '/onboard/payroll/agreement' elsif edi? '/onboard/edi/agreement' elsif ai_platform? '/onboard/ai_platform/agreement' end end |
#agreement_type ⇒ Object
149 150 151 152 153 154 155 156 157 |
# File 'app/models/app_mode.rb', line 149 def agreement_type if payroll? CompanyAgreement::PAYROLL_TYPE elsif edi? CompanyAgreement::EDI_TYPE elsif ai_platform? CompanyAgreement::AI_PLATFORM_TYPE end end |
#application_id ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'app/models/app_mode.rb', line 50 def application_id case mode when PAYROLL_MODE PAYROLL_MODE_APP_ID when EDI_MODE EDI_MODE_APP_ID when AI_PLATFORM_MODE AI_PLATFORM_MODE_APP_ID end end |
#can_register? ⇒ Boolean
189 190 191 |
# File 'app/models/app_mode.rb', line 189 def can_register? SpecialParameter.can_register?(application_id: application_id) end |
#company_details_path ⇒ Object
139 140 141 142 143 144 145 146 147 |
# File 'app/models/app_mode.rb', line 139 def company_details_path if payroll? '/onboard/payroll/company_details' elsif edi? '/onboard/edi/company_details' elsif ai_platform? '/onboard/ai_platform/company_details' end end |
#company_details_present?(company:) ⇒ Boolean
169 170 171 172 173 174 175 176 177 |
# File 'app/models/app_mode.rb', line 169 def company_details_present?(company:) if payroll? company.company_name_e.present? elsif edi? company.company_name_e.present? elsif ai_platform? company.company_name_e.present? end end |
#onboardable? ⇒ Boolean
115 116 117 |
# File 'app/models/app_mode.rb', line 115 def onboardable? payroll? || edi? || ai_platform? end |
#permission_groups_codes ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'app/models/app_mode.rb', line 102 def case mode when PAYROLL_MODE [PermissionGroup::Codes::PAYROLL_ADMIN] when EDI_MODE [PermissionGroup::Codes::EDI] when AI_PLATFORM_MODE [PermissionGroup::Codes::AI_PLATFORM] else [] end end |
#software_name ⇒ Object
119 120 121 122 123 124 125 126 127 |
# File 'app/models/app_mode.rb', line 119 def software_name if payroll? I18n.t('emails.by') elsif edi? 'edi2xml' elsif ai_platform? 'aiplatform' end end |
#supports_partner_by_company? ⇒ Boolean
87 88 89 |
# File 'app/models/app_mode.rb', line 87 def supports_partner_by_company? !payroll? end |
#system_record_home_path ⇒ Object
91 92 93 94 95 96 97 98 99 100 |
# File 'app/models/app_mode.rb', line 91 def system_record_home_path case mode when PAYROLL_MODE '/app/payroll' when EDI_MODE '/app/edi' when AI_PLATFORM_MODE '/app/ai/chat' end end |
#system_user_navigation_configuration ⇒ Object
72 73 74 |
# File 'app/models/app_mode.rb', line 72 def NavigationConfiguration.find() end |
#system_user_navigation_configuration_id ⇒ Object
76 77 78 79 80 81 82 83 84 85 |
# File 'app/models/app_mode.rb', line 76 def case mode when PAYROLL_MODE NavigationConfiguration::PAYROLL_SYSTEM_RECORD when EDI_MODE NavigationConfiguration::EDI_SYSTEM_RECORD when AI_PLATFORM_MODE NavigationConfiguration::AI_PLATFORM_SYSTEM_RECORD end end |
#user_navigation_configuration_id ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'app/models/app_mode.rb', line 61 def case mode when PAYROLL_MODE NavigationConfiguration::PAYROLL when EDI_MODE NavigationConfiguration::EDI when AI_PLATFORM_MODE NavigationConfiguration::AI_PLATFORM_SYSTEM_RECORD end end |
#web_uri ⇒ Object
179 180 181 182 183 184 185 186 187 |
# File 'app/models/app_mode.rb', line 179 def web_uri if payroll? Rails.application.config.payroll_web_ui_url elsif edi? Rails.application.config.edi_web_ui_url elsif ai_platform? Rails.application.config.ai_platform_web_ui_url end end |