Class: Tasker::DependentSystemObjectMap
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Tasker::DependentSystemObjectMap
- Defined in:
- app/models/tasker/dependent_system_object_map.rb
Class Method Summary collapse
Methods inherited from ApplicationRecord
configure_database_connections, database_configuration_exists?
Class Method Details
.find_or_create(system_one_name, system_one_id, system_two_name, system_two_id) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/models/tasker/dependent_system_object_map.rb', line 38 def self.find_or_create(system_one_name, system_one_id, system_two_name, system_two_id) system_one = Tasker::DependentSystem.find_or_create_by!(name: system_one_name) system_two = Tasker::DependentSystem.find_or_create_by!(name: system_two_name) # these could be in either order inst = where( remote_id_one: system_one_id, remote_id_two: system_two_id, dependent_system_one_id: system_one.dependent_system_id, dependent_system_two_id: system_two.dependent_system_id ).or( where( remote_id_one: system_two_id, remote_id_two: system_one_id, dependent_system_one_id: system_two.dependent_system_id, dependent_system_two_id: system_one.dependent_system_id ) ).first inst ||= create( remote_id_one: system_one_id, remote_id_two: system_two_id, dependent_system_one: system_one, dependent_system_two: system_two ) inst end |