Class: DorIndexing::Selectors::EventSelector
- Inherits:
-
Object
- Object
- DorIndexing::Selectors::EventSelector
- Defined in:
- lib/dor_indexing/selectors/event_selector.rb
Overview
Selects the best event to use for indexing
Class Method Summary collapse
-
.date_status_primary(date) ⇒ Boolean
True if date.status == primary.
-
.select(events, desired_date_type) ⇒ Cocina::Models::Event?
Event best matching selected.
Class Method Details
.date_status_primary(date) ⇒ Boolean
Returns true if date.status == primary.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dor_indexing/selectors/event_selector.rb', line 19 def self.date_status_primary(date) structured_primary = Array(date.structuredValue).find do |structured_date| structured_date.status == 'primary' end parallel_value_primary = Array(date.parallelValue).find do |parallel_value| parallel_value.status == 'primary' end date.status == 'primary' || structured_primary || parallel_value_primary end |
.select(events, desired_date_type) ⇒ Cocina::Models::Event?
Returns event best matching selected.
10 11 12 13 14 15 |
# File 'lib/dor_indexing/selectors/event_selector.rb', line 10 def self.select(events, desired_date_type) date_type_matches_and_primary(events, desired_date_type) || date_and_event_type_match(events, desired_date_type) || event_type_matches_but_no_date_type(events, desired_date_type) || event_has_date_type(events, desired_date_type) end |