module CruLib::GlobalRegistryRelationshipMethods
Public Instance Methods
async_push_to_global_registry()
click to toggle source
Calls superclass method
CruLib::GlobalRegistryMethods#async_push_to_global_registry
# File lib/cru_lib/global_registry_relationship_methods.rb, line 6 def async_push_to_global_registry super end
attributes_to_push(relationship_name: nil, related_name: nil, related_object: nil, base_object: nil)
click to toggle source
@param [String] relationship_name @param [String] related_name @param [Object] related_object
Calls superclass method
CruLib::GlobalRegistryMethods#attributes_to_push
# File lib/cru_lib/global_registry_relationship_methods.rb, line 20 def attributes_to_push(relationship_name: nil, related_name: nil, related_object: nil, base_object: nil) if global_registry_id attributes_to_push = super attributes_to_push else { "#{relationship_name}:relationship" => { client_integration_id: id, related_name => related_object.global_registry_id }, client_integration_id: base_object.id } end end
create_in_global_registry(base_object, relationship_name)
click to toggle source
@param [Object] base_object @param [String] relationship_name
# File lib/cru_lib/global_registry_relationship_methods.rb, line 37 def create_in_global_registry(base_object, relationship_name) entity = GlobalRegistry::Entity.put( base_object.global_registry_id, entity: { base_object.class.global_registry_entity_type_name => attributes_to_push(base_object: base_object) } ) base_object_id = entity['entity'][base_object.class.global_registry_entity_type_name]['id'] entity = GlobalRegistry::Entity.find(base_object_id)['entity'] global_registry_id = Array.wrap( entity[base_object.class.global_registry_entity_type_name]["#{relationship_name}:relationship"] ).detect do |hash| cid = hash['client_integration_id'] cid = cid['value'] if cid.is_a?(Hash) cid == id.to_s end['relationship_entity_id'] update_column(:global_registry_id, global_registry_id) update_in_global_registry end
delete_from_global_registry()
click to toggle source
TODO - deleting a relationship is different.
# File lib/cru_lib/global_registry_relationship_methods.rb, line 11 def delete_from_global_registry if global_registry_id Sidekiq::Client.enqueue(self.class, nil, :async_delete_from_global_registry, global_registry_id) end end