Class: Hyrax::Ingest::Ingester::ActiveFedoraPropertyAssigner

Inherits:
Object
  • Object
show all
Includes:
HasLogger, HasReport, Interloper
Defined in:
lib/hyrax/ingest/ingester/active_fedora_property_assigner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HasLogger

config, #logger, #logger=

Methods included from HasReport

#report, #report=

Constructor Details

#initialize(options = {}) ⇒ ActiveFedoraPropertyAssigner

Returns a new instance of ActiveFedoraPropertyAssigner.



21
22
23
24
25
26
27
28
# File 'lib/hyrax/ingest/ingester/active_fedora_property_assigner.rb', line 21

def initialize(options={})
  @rdf_predicate = options[:rdf_predicate]
  @fetcher = options[:fetcher]
  @af_model = options[:af_model]
  @transformer = options[:transformer]
  raise Hyrax::Ingest::Errors::UnknownActiveFedoraModel.new(@af_model.class) unless @af_model.is_a? ActiveFedora::Base
  raise Hyrax::Ingest::Errors::InvalidFetcher.new(@fetcher.class) unless @fetcher.is_a? Hyrax::Ingest::Fetcher::Base
end

Instance Attribute Details

#af_modelObject (readonly)

Returns the value of attribute af_model.



19
20
21
# File 'lib/hyrax/ingest/ingester/active_fedora_property_assigner.rb', line 19

def af_model
  @af_model
end

#fetcherObject (readonly)

Returns the value of attribute fetcher.



19
20
21
# File 'lib/hyrax/ingest/ingester/active_fedora_property_assigner.rb', line 19

def fetcher
  @fetcher
end

#rdf_predicateObject (readonly)

Returns the value of attribute rdf_predicate.



19
20
21
# File 'lib/hyrax/ingest/ingester/active_fedora_property_assigner.rb', line 19

def rdf_predicate
  @rdf_predicate
end

#transformerObject (readonly)

Returns the value of attribute transformer.



19
20
21
# File 'lib/hyrax/ingest/ingester/active_fedora_property_assigner.rb', line 19

def transformer
  @transformer
end

Instance Method Details

#assign!Object



30
31
32
33
34
35
# File 'lib/hyrax/ingest/ingester/active_fedora_property_assigner.rb', line 30

def assign!
  af_model.set_value(property_name, fetched_and_transformed_value)
rescue ::ActiveTriples::Relation::ValueError => e
  # Rethrow ActiveTriples::Relation::ValueError as something more specific to ingest.
  raise Hyrax::Ingest::Errors::InvalidActiveFedoraPropertyValue.new(fetched_value, property_name, rdf_predicate)
end