Class: Maestrano::Connector::Rails::Entity
- Inherits:
-
EntityBase
- Object
- EntityBase
- Maestrano::Connector::Rails::Entity
- Includes:
- Concerns::Entity
- Defined in:
- lib/generators/connector/templates/entity.rb,
app/models/maestrano/connector/rails/entity.rb
Direct Known Subclasses
Class Method Summary collapse
- .creation_date_from_external_entity_hash(entity) ⇒ Object
- .id_from_external_entity_hash(entity) ⇒ Object
- .inactive_from_external_entity_hash?(entity) ⇒ Boolean
- .last_update_date_from_external_entity_hash(entity) ⇒ Object
Instance Method Summary collapse
- #create_external_entity(mapped_connec_entity, external_entity_name) ⇒ Object
-
#get_external_entities(external_entity_name, last_synchronization_date = nil) ⇒ Object
Return an array of entities from the external app.
- #update_external_entity(mapped_connec_entity, external_id, external_entity_name) ⇒ Object
Class Method Details
.creation_date_from_external_entity_hash(entity) ⇒ Object
45 46 47 48 49 |
# File 'lib/generators/connector/templates/entity.rb', line 45 def self.creation_date_from_external_entity_hash(entity) # TODO # This method return the creation date from an external_entity_hash # e.g entity['created_at'] end |
.id_from_external_entity_hash(entity) ⇒ Object
33 34 35 36 37 |
# File 'lib/generators/connector/templates/entity.rb', line 33 def self.id_from_external_entity_hash(entity) # TODO # This method return the id from an external_entity_hash # e.g entity['id'] end |
.inactive_from_external_entity_hash?(entity) ⇒ Boolean
51 52 53 54 55 |
# File 'lib/generators/connector/templates/entity.rb', line 51 def self.inactive_from_external_entity_hash?(entity) # TODO # This method return true is entity is inactive in the external application # e.g entity['status'] == 'INACTIVE' end |
.last_update_date_from_external_entity_hash(entity) ⇒ Object
39 40 41 42 43 |
# File 'lib/generators/connector/templates/entity.rb', line 39 def self.last_update_date_from_external_entity_hash(entity) # TODO # This method return the last update date from an external_entity_hash # e.g entity['last_update'] end |
Instance Method Details
#create_external_entity(mapped_connec_entity, external_entity_name) ⇒ Object
21 22 23 24 25 |
# File 'lib/generators/connector/templates/entity.rb', line 21 def create_external_entity(mapped_connec_entity, external_entity_name) Maestrano::Connector::Rails::ConnectorLogger.log('info', @organization, "Sending create #{external_entity_name}: #{mapped_connec_entity} to #{Maestrano::Connector::Rails::External.external_name}") # TODO # This method creates the entity in the external app and returns the created external entity end |
#get_external_entities(external_entity_name, last_synchronization_date = nil) ⇒ Object
Return an array of entities from the external app
12 13 14 15 16 17 18 19 |
# File 'lib/generators/connector/templates/entity.rb', line 12 def get_external_entities(external_entity_name, last_synchronization_date = nil) Maestrano::Connector::Rails::ConnectorLogger.log('info', @organization, "Fetching #{Maestrano::Connector::Rails::External.external_name} #{self.class.external_entity_name.pluralize}") # TODO # This method should return only entities that have been updated since the last_synchronization_date # It should also implements an option to do a full synchronization when @opts[:full_sync] == true or when there is no last_synchronization_date # It should also support [:__limit] and [:__skip] opts, meaning that if they are present, it should return only @[:__limit] entities while skipping the @opts[:__skip] firsts # Maestrano::Connector::Rails::ConnectorLogger.log('info', @organization, "Received data: Source=#{Maestrano::Connector::Rails::External.external_name}, Entity=#{self.class.external_entity_name}, Response=#{entities}") end |
#update_external_entity(mapped_connec_entity, external_id, external_entity_name) ⇒ Object
27 28 29 30 31 |
# File 'lib/generators/connector/templates/entity.rb', line 27 def update_external_entity(mapped_connec_entity, external_id, external_entity_name) Maestrano::Connector::Rails::ConnectorLogger.log('info', @organization, "Sending update #{external_entity_name} (id=#{external_id}): #{mapped_connec_entity} to #{Maestrano::Connector::Rails::External.external_name}") # TODO # This method updates the entity with the given id in the external app and returns the created external entity end |