Created
July 15, 2015 18:32
-
-
Save mjgiarlo/25dc3f9c85baab1ccdf6 to your computer and use it in GitHub Desktop.
A pattern for handling CurationConcerns events in Sufia::Core
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# These events are triggered by actions within CurationConcerns Actors | |
CurationConcerns.config.after_create_content = lambda { |generic_file, user| | |
Sufia::CreateContentService.new(generic_file, user).call | |
# which will call CurationConcerns.queue.push(ContentDepositEventJob.new(generic_file.id, user.user_key)) | |
} | |
CurationConcerns.config.after_revert_content = lambda { |generic_file, user, revision| | |
Sufia::RevertContentService.new(generic_file, user, revision).call | |
# which will call CurationConcerns.queue.push(ContentRestoredVersionEventJob.new(generic_file.id, user.user_key, revision)) | |
} | |
CurationConcerns.config.after_update_content = lambda { |generic_file, user| | |
Sufia::UpdateContentService.new(generic_file, user).call | |
# which will call CurationConcerns.queue.push(ContentNewVersionEventJob.new(generic_file.id, user.user_key)) | |
} | |
CurationConcerns.config.after_update_metadata = lambda { |generic_file, user| | |
Sufia::UpdateMetadataService.new(generic_file, user).call | |
# which will call CurationConcerns.queue.push(ContentUpdateEventJob.new(generic_file.id, user.user_key)) | |
} | |
CurationConcerns.config.after_destroy = lambda { |destroyed_id, user| | |
Sufia::DestroyService.new(destroyed_id, user).call | |
# which will call CurationConcerns.queue.push(ContentDeleteEventJob.new(destroyed_id, user.user_key)) | |
} | |
CurationConcerns.config.after_audit_failure = lambda { |generic_file, user, log_date| | |
Sufia::AuditFailureService.new(generic_file, user, log_date).call | |
# which will call CurationConcerns.queue.push(AuditFailureEventJob.new(generic_file.id, user.user_key, log_date)) | |
} | |
CurationConcerns.config.after_import_url_success = lambda { |generic_file, user| | |
Sufia::ImportUrlSuccessService.new(generic_file, user).call | |
# which will call CurationConcerns.queue.push(ImportUrlSuccessEventJob.new(generic_file.id, user.user_key)) | |
# ... which in turn will call CurationConcerns.queue.push(ContentDepositEventJob.new(generic_file.id, user.user_key)) | |
} | |
CurationConcerns.config.after_import_url_failure = lambda { |generic_file, user| | |
Sufia::ImportUrlFailureService.new(generic_file, user).call | |
# which will call CurationConcerns.queue.push(ImportUrlFailureEventJob.new(generic_file.id, user.user_key)) | |
} | |
CurationConcerns.config.after_import_local_file_success = lambda { |generic_file, user, filename| | |
Sufia::ImportLocalFileSuccessService.new(generic_file, user, filename).call | |
# which will call CurationConcerns.queue.push(ImportLocalFileSuccessEventJob.new(generic_file.id, user.user_key, filename)) | |
} | |
CurationConcerns.config.after_import_local_file_failure = lambda { |generic_file, user, filename| | |
Sufia::ImportLocalFileFailureService.new(generic_file, user, filename).call | |
# which will call CurationConcerns.queue.push(ImportLocalFileFailureEventJob.new(generic_file.id, user.user_key, filename)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also (separate from previous comment): I suspect that CurationConcerns should be providing abstract classes for these services since it makes assumptions about what variables they will need (ie. it assumes that
after_import_local_file_failure
will needgeneric_file, user, filename
whileafter_audit_failure
will needgeneric_file, user, log_date
, but there's no spot for testing or documenting those assumptions.