Sha256: bec27ebdf6418e21b63d0f48061a3cd76bf282e02d06a0c7bf196ea59b3bc9e1
Contents?: true
Size: 1.61 KB
Versions: 1
Compression:
Stored size: 1.61 KB
Contents
require 'dmao_api' require 'dmao/api/person' require 'time' require 'dmao/ingesters/generic/ingester' require 'dmao/ingesters/errors/generic_ingester' require 'dmao/ingesters/errors/empty_attributes' require 'dmao/ingesters/errors/ingest_person_error' module DMAO module Ingesters module Generic class PeopleIngester < Ingester ENTITY = DMAO::API::Person ENTITY_ERROR = DMAO::Ingesters::Errors::IngestPersonError ENTITY_ERROR_MESSAGE = "Invalid person details" def ingest_person attributes={} ingest_entity attributes end private def add_entity attributes add_person attributes end def update_entity id, attributes update_person id, attributes end def add_person attributes begin DMAO::API::Person.create attributes rescue DMAO::API::Errors::InstitutionNotFound raise DMAO::Ingesters::Errors::IngestPersonError.new("Institution not found, cannot ingest person to non-existent institution") rescue DMAO::API::Errors::InvalidPerson => e parse_unprocessable_errors(e.errors) end end def update_person id, attributes begin DMAO::API::Person.update id, attributes rescue DMAO::API::Errors::PersonNotFound raise DMAO::Ingesters::Errors::IngestPersonError.new("Person not found, cannot update person that does not exist") rescue DMAO::API::Errors::InvalidPerson => e parse_unprocessable_errors(e.errors) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dmao-generic-ingesters-0.3.0 | lib/dmao/ingesters/generic/people_ingester.rb |