Class: Itchy::MetadataArchiver
- Inherits:
-
Object
- Object
- Itchy::MetadataArchiver
- Defined in:
- lib/itchy/metadata_archiver.rb
Overview
Wraps vmcatcher event handling methods. All events are stored for subsequent processing. There is no actual image handling happening here.
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#vmc_configuration ⇒ Object
readonly
Returns the value of attribute vmc_configuration.
Instance Method Summary collapse
-
#archive!(vmc_event) ⇒ Object
Triggers archiving of the provided event.
-
#initialize(vmc_configuration, options) ⇒ MetadataArchiver
constructor
Creates an archiver instance for storing vmcatcher events to the file system for delayed processing.
Constructor Details
#initialize(vmc_configuration, options) ⇒ MetadataArchiver
Creates an archiver instance for storing vmcatcher events to the file system for delayed processing.
13 14 15 16 17 18 19 20 21 |
# File 'lib/itchy/metadata_archiver.rb', line 13 def initialize(vmc_configuration, ) fail ArgumentError, '"vmc_configuration" must be an instance ' \ 'of Itchy::VmcatcherConfiguration' unless vmc_configuration.is_a? Itchy::VmcatcherConfiguration @vmc_configuration = vmc_configuration @options = || ::Hashie::Mash.new end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/itchy/metadata_archiver.rb', line 6 def @options end |
#vmc_configuration ⇒ Object (readonly)
Returns the value of attribute vmc_configuration.
6 7 8 |
# File 'lib/itchy/metadata_archiver.rb', line 6 def vmc_configuration @vmc_configuration end |
Instance Method Details
#archive!(vmc_event) ⇒ Object
Triggers archiving of the provided event. Event is written to the file system as a JSON-formatted document for delayed processing.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/itchy/metadata_archiver.rb', line 28 def archive!(vmc_event) fail ArgumentError, '"vmc_event" must be an instance ' \ 'of Itchy::VmcatcherEvent' unless vmc_event.is_a? Itchy::VmcatcherEvent Itchy::Log.info "[#{self.class.name}] Archiving " \ "#{vmc_event.type.inspect} " \ "for #{vmc_event.dc_identifier.inspect}" begin event_handler = Itchy::EventHandlers.const_get("#{vmc_event.type}EventHandler") rescue NameError => ex fail Itchy::Errors::UnknownEventError, "Unknown event type #{vmc_event.type.inspect} detected: #{ex.}" end event_handler = event_handler.new(vmc_configuration, ) event_handler.archive!(vmc_event) end |