Module: Event::RequestDescriptorUpdateEvent

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


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

def self.included(base)
  base.after_create(:update_metadata_for_request, if: ->(event) { event.eventful.is_a?(Request) and not event.descriptor_key.blank? })
end

Instance Method Details

#library_creation_descriptor?Boolean

Returns:

  • (Boolean)

10
11
12
# File 'app/models/event/request_descriptor_update_event.rb', line 10

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

#pass_or_fail_event?Boolean

Returns:

  • (Boolean)

6
7
8
# File 'app/models/event/request_descriptor_update_event.rb', line 6

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

#set_request_metadataObject


14
15
16
17
# File 'app/models/event/request_descriptor_update_event.rb', line 14

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

#update_metadata_for_requestObject


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

def 
  request = eventful
   unless pass_or_fail_event?

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

  return if pass_or_fail_event?

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