Module: GlobalRegistry::Bindings::Entity::MdmMethods
- Extended by:
- ActiveSupport::Concern
- Included in:
- Workers::PullMdmIdWorker
- Defined in:
- lib/global_registry_bindings/entity/mdm_methods.rb
Instance Method Summary collapse
- #dig_global_registry_mdm_id_from_entity(entity, type) ⇒ Object
-
#pull_mdm_id_from_global_registry ⇒ Object
rubocop:disable Metrics/AbcSize.
Instance Method Details
#dig_global_registry_mdm_id_from_entity(entity, type) ⇒ Object
26 27 28 29 30 |
# File 'lib/global_registry_bindings/entity/mdm_methods.rb', line 26 def dig_global_registry_mdm_id_from_entity(entity, type) Array.wrap(entity.dig("entity", type, "master_#{type}:relationship")) .first # although there should not be more than one .try(:[], "master_#{type}") end |
#pull_mdm_id_from_global_registry ⇒ Object
rubocop:disable Metrics/AbcSize
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/global_registry_bindings/entity/mdm_methods.rb', line 9 def pull_mdm_id_from_global_registry # rubocop:disable Metrics/AbcSize unless global_registry_entity.id_value? # Record missing Global Registry ID, enqueue it to be pushed. model.push_entity_to_global_registry_async raise GlobalRegistry::Bindings::RecordMissingGlobalRegistryId, "#{model.class.name}(#{model.id}) has no #{global_registry_entity.id_column}; will retry" end entity = GlobalRegistry::Entity.find(global_registry_entity.id_value, "filters[owned_by]" => "mdm") mdm_entity_id = dig_global_registry_mdm_id_from_entity(entity, global_registry_entity.type.to_s) unless mdm_entity_id raise GlobalRegistry::Bindings::EntityMissingMdmId, "GR entity #{global_registry_entity.id_value} for #{model.class.name}(#{model.id}) has no mdm id; " \ "will retry" end model.update_column(global_registry_entity.mdm_id_column, mdm_entity_id) # rubocop:disable Rails/SkipsModelValidations end |