Module: Event::RequestDescriptorUpdateEvent

Included in:
Event
Defined in:
app/models/event/request_descriptor_update_event.rb

Overview

rubocop:todo Style/Documentation

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


2
3
4
5
6
# File 'app/models/event/request_descriptor_update_event.rb', line 2

def self.included(base)
  base.after_create(:update_metadata_for_request, if: lambda { |event|
                                                        event.eventful.is_a?(Request) and event.descriptor_key.present?
                                                      })
end

Instance Method Details

#library_creation_descriptor?Boolean

Returns:

  • (Boolean)

12
13
14
# File 'app/models/event/request_descriptor_update_event.rb', line 12

def library_creation_descriptor?
  %w[library_creation_complete multiplexed_library_creation].include?(descriptor_key)
end

#pass_or_fail_event?Boolean

Returns:

  • (Boolean)

8
9
10
# File 'app/models/event/request_descriptor_update_event.rb', line 8

def pass_or_fail_event?
  %w[fail pass].include?(family)
end

#set_request_metadataObject


16
17
18
19
# File 'app/models/event/request_descriptor_update_event.rb', line 16

def 
  eventful.[descriptor_key] = content
  eventful..save!
end

#update_metadata_for_requestObject


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/models/event/request_descriptor_update_event.rb', line 21

def 
   unless pass_or_fail_event?

  if request.failed? || request.cancelled?
    
    return
  end

  return if pass_or_fail_event?

  if library_creation_descriptor?
    request.pass!
  else
    request.start!
  end
end