Module: CruLib::GlobalRegistryMasterPersonMethods

Extended by:
ActiveSupport::Concern
Includes:
GlobalRegistryMethods
Defined in:
lib/cru_lib/global_registry_master_person_methods.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Methods included from GlobalRegistryMethods

#async_push_to_global_registry, #attributes_to_push, #create_in_global_registry, #delete_from_global_registry, #push_to_global_registry, #update_in_global_registry

Methods included from Async

#async, #perform

Instance Method Details

#async_retrieve_gr_master_person_idObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cru_lib/global_registry_master_person_methods.rb', line 15

def async_retrieve_gr_master_person_id
  fail CruLib::NoGlobalRegistryIdError, "Person #{id} has no global_registry_id; will retry" unless global_registry_id
  begin
    person_entity = GlobalRegistry::Entity.find(global_registry_id, 'filters[owned_by]' => 'mdm')
  rescue RestClient::ResourceNotFound
    Rails.logger.info "GR entity #{global_registry_id} for Person #{id} does not exist; will _not_ retry"
    return
  end
  mdm_entity_id = Array.wrap(person_entity.dig('entity', 'person', 'master_person:relationship'))
                      .first # although there should not be more than one
                      .try(:[], 'master_person')
  fail CruLib::NoGlobalRegistryMasterPersonError, "GR entity #{global_registry_id} for Person #{id} has no master_person; will retry" unless mdm_entity_id
  update_columns(gr_master_person_id: mdm_entity_id)
end

#retrieve_gr_master_person_idObject



10
11
12
13
# File 'lib/cru_lib/global_registry_master_person_methods.rb', line 10

def retrieve_gr_master_person_id
  return unless respond_to?(:gr_master_person_id)
  async("async_retrieve_gr_master_person_id")
end