Class: EventJob

Inherits:
ActiveJob::Base
  • Object
show all
Includes:
ActionView::Helpers, ActionView::Helpers::DateHelper, Hydra::AccessControlsEnforcement, HyraxHelper
Defined in:
app/jobs/event_job.rb

Overview

A generic job for sending events to a user.

This class does not implement a usable action, so it must be implemented in a child class

Constant Summary

Constants included from Hyrax::CitationsBehaviors::TitleBehavior

Hyrax::CitationsBehaviors::TitleBehavior::EXPANDED_NOCAPS, Hyrax::CitationsBehaviors::TitleBehavior::TITLE_NOCAPS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Hyrax::HyraxHelperBehavior

#available_translations, #banner_image, #browser_supports_directory_upload?, #collection_thumbnail, #current_search_parameters, #human_readable_date, #iconify_auto_link, #index_field_link, #license_links, #link_to_each_facet_field, #link_to_facet, #link_to_facet_list, #link_to_field, #link_to_profile, #link_to_telephone, #orcid_label, #search_form_action, #show_transfer_request_title, #user_display_name_and_key, #zotero_label, #zotero_profile_url

Methods included from Hyrax::DashboardHelperBehavior

#link_to_additional_notifications, #notifications_for_dashboard, #number_of_collections, #number_of_files, #number_of_works, #on_my_works?, #on_the_dashboard?, #render_received_transfers, #render_recent_activity, #render_recent_notifications, #render_sent_transfers

Methods included from Hyrax::ChartsHelper

#hash_to_chart

Methods included from Hyrax::CollectionsHelper

#button_for_remove_from_collection, #button_for_remove_selected_from_collection, #has_collection_search_parameters?, #render_collection_links, #single_item_action_remove_form_fields

Methods included from Hyrax::LeaseHelper

#assets_under_lease, #assets_with_deactivated_leases, #assets_with_expired_leases

Methods included from Hyrax::EmbargoHelper

#assets_under_embargo, #assets_with_deactivated_embargoes, #assets_with_expired_embargoes

Methods included from Hyrax::AbilityHelper

#render_visibility_link, #visibility_badge, #visibility_options

Methods included from Hyrax::SearchPathsHelper

#search_path_for_my_collections, #search_path_for_my_works

Methods included from Hyrax::FileSetHelper

#media_display, #media_display_partial, #parent_path

Methods included from Hyrax::TitleHelper

#application_name, #construct_page_title, #curation_concern_page_title, #default_page_title

Methods included from Hyrax::CitationsBehavior

#export_as_apa_citation, #export_as_chicago_citation, #export_as_mla_citation, #export_as_openurl_ctx_kev

Methods included from Hyrax::CitationsBehaviors::TitleBehavior

#chicago_citation_title, #mla_citation_title, #process_title_parts, #setup_title_info

Methods included from Hyrax::CitationsBehaviors::CommonBehavior

#clean_end_punctuation, #persistent_url

Methods included from Hyrax::CitationsBehaviors::NameBehavior

#abbreviate_name, #all_authors, #author_list, #given_name_first, #surname_first

Methods included from Hyrax::CitationsBehaviors::PublicationBehavior

#setup_pub_date, #setup_pub_info, #setup_pub_place, #setup_pub_publisher

Methods included from Hyrax::BlacklightOverride

#application_name

Instance Attribute Details

#depositorObject (readonly)

Returns the value of attribute depositor.



13
14
15
# File 'app/jobs/event_job.rb', line 13

def depositor
  @depositor
end

Instance Method Details

#actionObject

This method is abstract.

override to provide your specific action for the event you are logging

Raises:

  • (NotImplementedError)


24
25
26
# File 'app/jobs/event_job.rb', line 24

def action
  raise(NotImplementedError, "#action should be implemented by an child class of EventJob")
end

#eventObject

create an event with an action and a timestamp for the user



29
30
31
# File 'app/jobs/event_job.rb', line 29

def event
  @event ||= Hyrax::Event.create(action, Time.current.to_i)
end

#log_user_event(depositor) ⇒ Object

log the event to the users event stream



34
35
36
# File 'app/jobs/event_job.rb', line 34

def log_user_event(depositor)
  depositor.log_event(event)
end

#perform(depositor) ⇒ Object

Parameters:

  • depositor (User)

    the user to create the event for



16
17
18
19
20
# File 'app/jobs/event_job.rb', line 16

def perform(depositor)
  @depositor = depositor
  # Log the event to the depositor's profile stream
  log_user_event(depositor)
end