Class: EventJob
- Inherits:
-
Object
- Object
- EventJob
- Includes:
- ActionView::Helpers, ActionView::Helpers::DateHelper, Hydra::AccessControlsEnforcement, SufiaHelper
- Defined in:
- app/jobs/event_job.rb
Overview
A generic job for sending events to a user and their followers.
This class does not implement a usable action, so it must be implemented in a child class
Direct Known Subclasses
ContentDeleteEventJob, ContentEventJob, UserEditProfileEventJob, UserFollowEventJob, UserUnfollowEventJob
Instance Attribute Summary collapse
-
#depositor_id ⇒ String
the user the event is specified for.
Instance Method Summary collapse
-
#action ⇒ Object
abstract
override to provide your specific action for the event you are logging.
-
#depositor ⇒ Object
the user that will be the subject of the event.
-
#event ⇒ Object
create an event with an action and a timestamp for the user.
-
#initialize(depositor_id) ⇒ EventJob
constructor
A new instance of EventJob.
-
#log_to_followers ⇒ Object
log the event to the users followers.
-
#log_user_event ⇒ Object
log the event to the users event stream.
-
#queue_name ⇒ Object
queue to run the job on.
-
#run ⇒ Object
Method used to cause the event to be created.
Methods included from Sufia::SufiaHelperBehavior
#current_search_parameters, #display_user_name, #error_messages_for, #has_collection_search_parameters?, #iconify_auto_link, #iconify_link, #is_url?, #link_back_to_dashboard, #link_to_dashboard_query, #link_to_facet, #link_to_facet_list, #link_to_field, #link_to_profile, #link_to_telephone, #linkify_chat_id, #number_of_deposits, #orcid_label, #render_visibility_label, #render_visibility_link, #search_form_action, #show_transfer_request_title, #sufia_thumbnail_tag, #user_display_name_and_key, #zotero_label, #zotero_profile_url
Methods included from Sufia::BlacklightOverride
#render_bookmarks_control?, #render_constraints_query, #url_for_document
Constructor Details
#initialize(depositor_id) ⇒ EventJob
Returns a new instance of EventJob.
22 23 24 |
# File 'app/jobs/event_job.rb', line 22 def initialize(depositor_id) @depositor_id = depositor_id end |
Instance Attribute Details
#depositor_id ⇒ String
the user the event is specified for
7 8 9 |
# File 'app/jobs/event_job.rb', line 7 def depositor_id @depositor_id end |
Instance Method Details
#action ⇒ Object
override to provide your specific action for the event you are logging
37 38 39 |
# File 'app/jobs/event_job.rb', line 37 def action raise(NotImplementedError, "#action should be implemented by an child class of EventJob") end |
#depositor ⇒ Object
the user that will be the subject of the event
47 48 49 |
# File 'app/jobs/event_job.rb', line 47 def depositor @depositor ||= User.find_by_user_key(depositor_id) end |
#event ⇒ Object
create an event with an action and a timestamp for the user
42 43 44 |
# File 'app/jobs/event_job.rb', line 42 def event @event ||= depositor.create_event(action, Time.now.to_i) end |
#log_to_followers ⇒ Object
log the event to the users followers
57 58 59 60 61 |
# File 'app/jobs/event_job.rb', line 57 def log_to_followers depositor.followers.each do |follower| follower.log_event(event) end end |
#log_user_event ⇒ Object
log the event to the users event stream
52 53 54 |
# File 'app/jobs/event_job.rb', line 52 def log_user_event depositor.log_event(event) end |
#queue_name ⇒ Object
queue to run the job on
15 16 17 |
# File 'app/jobs/event_job.rb', line 15 def queue_name :event end |
#run ⇒ Object
Method used to cause the event to be created
27 28 29 30 31 32 33 |
# File 'app/jobs/event_job.rb', line 27 def run # Log the event to the depositor's profile stream log_user_event # Fan out the event to all followers who have access log_to_followers end |