Class: ActiveFedora::FixityService

Inherits:
Object
  • Object
show all
Extended by:
ActiveSupport::Concern
Defined in:
lib/active_fedora/fixity_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ FixityService

Returns a new instance of FixityService.

Parameters:

  • target (String, RDF::URI)

    url for a Fedora resource

Raises:

  • (ArgumentError)


8
9
10
11
# File 'lib/active_fedora/fixity_service.rb', line 8

def initialize(target)
  raise ArgumentError, 'You must provide a uri' unless target
  @target = target.to_s
end

Instance Attribute Details

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/active_fedora/fixity_service.rb', line 5

def response
  @response
end

#targetObject

Returns the value of attribute target.



5
6
7
# File 'lib/active_fedora/fixity_service.rb', line 5

def target
  @target
end

Instance Method Details

#checkObject

Executes a fixity check on Fedora and saves the Faraday::Response.

Returns:

  • true or false



15
16
17
18
# File 'lib/active_fedora/fixity_service.rb', line 15

def check
  @response = fixity_response_from_fedora
  status.include?(success)
end

#statusObject



20
21
22
23
# File 'lib/active_fedora/fixity_service.rb', line 20

def status
  fixity_graph.query(predicate: premis_status_predicate).map(&:object) +
    fixity_graph.query(predicate: fedora_status_predicate).map(&:object)
end