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.
-
#physical_path ⇒ Object
Returns the value of attribute physical_path.
-
#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, physical_path: 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, physical_path: nil) ⇒ MetadataRecord
Returns a new instance of MetadataRecord.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/longleaf/models/metadata_record.rb', line 23 def initialize(properties: nil, services: nil, deregistered: nil, registered: nil, checksums: nil, file_size: nil, last_modified: nil, physical_path: nil) @properties = properties || Hash.new @registered = registered @deregistered = deregistered @checksums = CaseInsensitiveHash.new @checksums.merge!(checksums) unless checksums.nil? @services = services || Hash.new @file_size = file_size @last_modified = last_modified @physical_path = physical_path end |
Instance Attribute Details
#checksums ⇒ Object (readonly)
Returns the value of attribute checksums.
10 11 12 |
# File 'lib/longleaf/models/metadata_record.rb', line 10 def checksums @checksums end |
#deregistered ⇒ Object
Returns the value of attribute deregistered.
9 10 11 |
# File 'lib/longleaf/models/metadata_record.rb', line 9 def deregistered @deregistered end |
#file_size ⇒ Object
Returns the value of attribute file_size.
12 13 14 |
# File 'lib/longleaf/models/metadata_record.rb', line 12 def file_size @file_size end |
#last_modified ⇒ Object
Returns the value of attribute last_modified.
12 13 14 |
# File 'lib/longleaf/models/metadata_record.rb', line 12 def last_modified @last_modified end |
#physical_path ⇒ Object
Returns the value of attribute physical_path.
13 14 15 |
# File 'lib/longleaf/models/metadata_record.rb', line 13 def physical_path @physical_path end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
11 12 13 |
# File 'lib/longleaf/models/metadata_record.rb', line 11 def properties @properties end |
#registered ⇒ Object (readonly)
Returns the value of attribute registered.
8 9 10 |
# File 'lib/longleaf/models/metadata_record.rb', line 8 def registered @registered end |
Instance Method Details
#add_service(name, service = ServiceRecord.new) ⇒ ServiceRecord
Adds a service to this record
46 47 48 49 50 51 |
# File 'lib/longleaf/models/metadata_record.rb', line 46 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.
37 38 39 |
# File 'lib/longleaf/models/metadata_record.rb', line 37 def deregistered? !@deregistered.nil? end |
#list_services ⇒ Array<String>
Returns a list of name identifiers for services registered to this record.
80 81 82 |
# File 'lib/longleaf/models/metadata_record.rb', line 80 def list_services @services.keys end |
#service(name) ⇒ ServiceRecord
Returns the ServiceRecord for the service identified by name, or nil.
75 76 77 |
# File 'lib/longleaf/models/metadata_record.rb', line 75 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.
67 68 69 70 71 |
# File 'lib/longleaf/models/metadata_record.rb', line 67 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.
56 57 58 59 60 61 |
# File 'lib/longleaf/models/metadata_record.rb', line 56 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 |