Class: BroadcastEvent
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- BroadcastEvent
- Extended by:
- MetadataHelpers::MetadatableClassMethods, RenderHelpers::RenderableClassMethods, SubjectHelpers::SubjectableClassMethods
- Includes:
- Uuid::Uuidable
- Defined in:
- app/models/broadcast_event.rb
Overview
Abstract class used to generate events; use subclass to specify how your particular event is generated.
Direct Known Subclasses
AssetAudit, LabEvent, LabwareFailed, LabwareReceived, LibraryComplete, LibraryStart, OrderMade, PlateCherrypicked, PlateLibraryComplete, PoolReleased, QcAssay, SampleManifestCreated, SampleManifestUpdated, SequencingComplete, SequencingStart, LibraryEvent
Defined Under Namespace
Modules: Helpers, MetadataHelpers, RenderHelpers, SubjectHelpers Classes: AssetAudit, LabEvent, LabwareFailed, LabwareReceived, LibraryComplete, LibraryStart, OrderMade, PlateCherrypicked, PlateLibraryComplete, PoolReleased, QcAssay, SampleManifestCreated, SampleManifestUpdated, SequencingComplete, SequencingStart
Constant Summary collapse
- EVENT_JSON_ROOT =
'event'
- UNKNOWN_USER_IDENTIFIER =
'UNKNOWN'
Class Attribute Summary collapse
-
.event_type ⇒ Object
readonly
Returns the value of attribute event_type.
Class Method Summary collapse
-
.set_event_type(event_type) ⇒ String
Use in subclasses to specify a fixed event type.
Instance Method Summary collapse
-
#event_type ⇒ String
Override in subclasses if you want dynamic event types.
-
#json_root ⇒ String
The root of the generated json object.
-
#metadata ⇒ Object
Returns a hash of all metadata.
-
#routing_key ⇒ String
Routing key generated for the broadcasted event.
-
#subjects ⇒ Object
Returns an array of all subjects.
-
#user_identifier ⇒ Object
Prefer email, fall back to login if missing.
Methods included from SubjectHelpers::SubjectableClassMethods
has_subject, has_subjects, seed_class, seed_subject, subject_associations
Methods included from MetadataHelpers::MetadatableClassMethods
has_metadata, metadata_finders
Methods included from RenderHelpers::RenderableClassMethods
Methods included from Uuid::Uuidable
included, #unsaved_uuid!, #uuid
Methods inherited from ApplicationRecord
alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!
Methods included from Squishify
Class Attribute Details
.event_type ⇒ Object (readonly)
Returns the value of attribute event_type.
72 73 74 |
# File 'app/models/broadcast_event.rb', line 72 def event_type @event_type end |
Class Method Details
.set_event_type(event_type) ⇒ String
Use in subclasses to specify a fixed event type
66 67 68 |
# File 'app/models/broadcast_event.rb', line 66 def self.set_event_type(event_type) @event_type = event_type end |
Instance Method Details
#event_type ⇒ String
Override in subclasses if you want dynamic event types
57 58 59 |
# File 'app/models/broadcast_event.rb', line 57 def event_type self.class.event_type end |
#json_root ⇒ String
Returns the root of the generated json object. ‘event’.
51 52 53 |
# File 'app/models/broadcast_event.rb', line 51 def json_root EVENT_JSON_ROOT end |
#metadata ⇒ Object
Returns a hash of all metadata
40 41 42 |
# File 'app/models/broadcast_event.rb', line 40 def self.class..to_h { |mf| mf.for(seed, self) } end |
#routing_key ⇒ String
Routing key generated for the broadcasted event.
46 47 48 |
# File 'app/models/broadcast_event.rb', line 46 def routing_key "event.#{event_type}.#{id}" end |
#subjects ⇒ Object
Returns an array of all subjects
35 36 37 |
# File 'app/models/broadcast_event.rb', line 35 def subjects self.class.subject_associations.flat_map { |sa| sa.for(seed, self) }.select(&:broadcastable?) end |
#user_identifier ⇒ Object
Prefer email, fall back to login if missing
28 29 30 31 32 |
# File 'app/models/broadcast_event.rb', line 28 def user_identifier return UNKNOWN_USER_IDENTIFIER if user.nil? # User has probably been deleted user.email.presence || user.login end |