class Darlingtonia::InputRecord
@example Building an importer with the factory
record = InputRecord.from({some: :metadata}, mapper: MyMapper.new) record.some # => :metadata
Attributes
mapper[RW]
@!attribute [rw] mapper
@return [#map_fields]
Public Class Methods
from(metadata:, mapper: HyraxBasicMetadataMapper.new)
click to toggle source
@param metadata [Object] @param mapper [#map_fields]
@return [InputRecord] an input record mapping metadata with the given
mapper
# File lib/darlingtonia/input_record.rb, line 28 def from(metadata:, mapper: HyraxBasicMetadataMapper.new) mapper.metadata = metadata new(mapper: mapper) end
new(mapper: HyraxBasicMetadataMapper.new)
click to toggle source
@param mapper [#map_fields]
# File lib/darlingtonia/input_record.rb, line 17 def initialize(mapper: HyraxBasicMetadataMapper.new) self.mapper = mapper end
Public Instance Methods
attributes()
click to toggle source
@return [Hash<Symbol, Object>]
# File lib/darlingtonia/input_record.rb, line 36 def attributes mapper.fields.each_with_object({}) do |field, attrs| attrs[field] = public_send(field) end end
method_missing(method_name, *args, &block)
click to toggle source
Respond to methods matching mapper fields
Calls superclass method
# File lib/darlingtonia/input_record.rb, line 54 def method_missing(method_name, *args, &block) return super unless mapper.field?(method_name) mapper.public_send(method_name) end
representative_file()
click to toggle source
@return [String, nil] an identifier for the representative file; nil if
none is given.
# File lib/darlingtonia/input_record.rb, line 45 def representative_file return mapper.representative_file if mapper.respond_to?(:representative_file) nil end
respond_to_missing?(method_name, include_private = false)
click to toggle source
@see method_missing
Calls superclass method
# File lib/darlingtonia/input_record.rb, line 61 def respond_to_missing?(method_name, include_private = false) mapper.field?(method_name) || super end