Class: Longleaf::MetadataRecord
- Inherits:
-
Object
- Object
- Longleaf::MetadataRecord
- Defined in:
- lib/longleaf/models/metadata_record.rb
Overview
Metadata record for a single file
Instance Attribute Summary collapse
-
#checksums ⇒ Object
readonly
Returns the value of attribute checksums.
-
#deregistered ⇒ Object
Returns the value of attribute deregistered.
-
#file_size ⇒ Object
Returns the value of attribute file_size.
-
#last_modified ⇒ Object
Returns the value of attribute last_modified.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#registered ⇒ Object
readonly
Returns the value of attribute registered.
Instance Method Summary collapse
-
#add_service(name, service = ServiceRecord.new) ⇒ ServiceRecord
Adds a service to this record.
-
#deregistered? ⇒ Boolean
True if the record is deregistered.
-
#initialize(properties: nil, services: nil, deregistered: nil, registered: nil, checksums: nil, file_size: nil, last_modified: nil) ⇒ MetadataRecord
constructor
A new instance of MetadataRecord.
-
#list_services ⇒ Array<String>
A list of name identifiers for services registered to this record.
-
#service(name) ⇒ ServiceRecord
The ServiceRecord for the service identified by name, or nil.
-
#update_service_as_failed(service_name) ⇒ ServiceRecord
Updates details of service record as if the service had encountered a failure during execution.
-
#update_service_as_performed(service_name) ⇒ ServiceRecord
Updates details of service record as if the service had been executed.
Constructor Details
#initialize(properties: nil, services: nil, deregistered: nil, registered: nil, checksums: nil, file_size: nil, last_modified: nil) ⇒ MetadataRecord
Returns a new instance of MetadataRecord
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/longleaf/models/metadata_record.rb', line 20 def initialize(properties: nil, services: nil, deregistered: nil, registered: nil, checksums: nil, file_size: nil, last_modified: nil) @properties = properties || Hash.new @registered = registered @deregistered = deregistered @checksums = checksums || Hash.new @services = services || Hash.new @file_size = file_size @last_modified = last_modified end |
Instance Attribute Details
#checksums ⇒ Object (readonly)
Returns the value of attribute checksums
9 10 11 |
# File 'lib/longleaf/models/metadata_record.rb', line 9 def checksums @checksums end |
#deregistered ⇒ Object
Returns the value of attribute deregistered
8 9 10 |
# File 'lib/longleaf/models/metadata_record.rb', line 8 def deregistered @deregistered end |
#file_size ⇒ Object
Returns the value of attribute file_size
11 12 13 |
# File 'lib/longleaf/models/metadata_record.rb', line 11 def file_size @file_size end |
#last_modified ⇒ Object
Returns the value of attribute last_modified
11 12 13 |
# File 'lib/longleaf/models/metadata_record.rb', line 11 def last_modified @last_modified end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties
10 11 12 |
# File 'lib/longleaf/models/metadata_record.rb', line 10 def properties @properties end |
#registered ⇒ Object (readonly)
Returns the value of attribute registered
7 8 9 |
# File 'lib/longleaf/models/metadata_record.rb', line 7 def registered @registered end |
Instance Method Details
#add_service(name, service = ServiceRecord.new) ⇒ ServiceRecord
Adds a service to this record
41 42 43 44 45 46 |
# File 'lib/longleaf/models/metadata_record.rb', line 41 def add_service(name, service = ServiceRecord.new) raise ArgumentError.new("Value must be a ServiceRecord object when adding a service") unless service.class == Longleaf::ServiceRecord raise IndexError.new("Service with name '#{name}' already exists") if @services.key?(name) @services[name] = service end |
#deregistered? ⇒ Boolean
Returns true if the record is deregistered
32 33 34 |
# File 'lib/longleaf/models/metadata_record.rb', line 32 def deregistered? !@deregistered.nil? end |
#list_services ⇒ Array<String>
Returns a list of name identifiers for services registered to this record
75 76 77 |
# File 'lib/longleaf/models/metadata_record.rb', line 75 def list_services @services.keys end |
#service(name) ⇒ ServiceRecord
Returns the ServiceRecord for the service identified by name, or nil
70 71 72 |
# File 'lib/longleaf/models/metadata_record.rb', line 70 def service(name) @services[name] end |
#update_service_as_failed(service_name) ⇒ ServiceRecord
Updates details of service record as if the service had encountered a failure during execution.
62 63 64 65 66 |
# File 'lib/longleaf/models/metadata_record.rb', line 62 def update_service_as_failed(service_name) service_rec = service(service_name) || add_service(service_name) service_rec. = ServiceDateHelper. service_rec end |
#update_service_as_performed(service_name) ⇒ ServiceRecord
Updates details of service record as if the service had been executed.
51 52 53 54 55 56 |
# File 'lib/longleaf/models/metadata_record.rb', line 51 def update_service_as_performed(service_name) service_rec = service(service_name) || add_service(service_name) service_rec.run_needed = false service_rec. = ServiceDateHelper. service_rec end |