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 when the fixity check was successfully.



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

def check
  @response = get_fixity_response_from_fedora
  status.match("SUCCESS") ? true : false
end

#statusObject



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

def status
  fixity_graph.query(predicate: ActiveFedora::RDF::Fcrepo4.status).map(&:object).first.to_s
end