Class: GalterIrExporter::Export::Actor

Inherits:
Object
  • Object
show all
Defined in:
lib/galter_ir_exporter/export/actor.rb

Overview

Convert a GenericFile including metadata, permissions and version metadata into a PORO so that the metadata can be exported in json format using to_json

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeActor

initialize the class with the default registry



11
12
13
# File 'lib/galter_ir_exporter/export/actor.rb', line 11

def initialize
  @converter_registry = default_registry
end

Instance Attribute Details

#conversion_countObject

Returns the value of attribute conversion_count.



8
9
10
# File 'lib/galter_ir_exporter/export/actor.rb', line 8

def conversion_count
  @conversion_count
end

#converter_registryObject (readonly)

Returns the value of attribute converter_registry.



7
8
9
# File 'lib/galter_ir_exporter/export/actor.rb', line 7

def converter_registry
  @converter_registry
end

#idsObject (readonly)

Returns the value of attribute ids.



7
8
9
# File 'lib/galter_ir_exporter/export/actor.rb', line 7

def ids
  @ids
end

#limitObject (readonly)

Returns the value of attribute limit.



7
8
9
# File 'lib/galter_ir_exporter/export/actor.rb', line 7

def limit
  @limit
end

Instance Method Details

#call(model_class_list = converter_registry.keys, opts = {}) ⇒ Object

Convert the classes using the registered converters from ActiveFedora to json files

Parameters:

  • model_class_list (Array) (defaults to: converter_registry.keys)

    list of classes to be converter

  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :limit (Number)

    Limits the number of conversion done (defaults to -1 or all)

  • :ids (Array)

    List of ids to be converted. Can be from any model



31
32
33
34
35
36
# File 'lib/galter_ir_exporter/export/actor.rb', line 31

def call(model_class_list = converter_registry.keys, opts = {})
  @conversion_count = 0
  validate_class_list(model_class_list)
  parse_options(opts)
  export_models(model_class_list)
end

#register_converter(model_class, converter_class) ⇒ Object

register a converter for a new class or overwrite the converter for a default class

Parameters:

  • model_class (Class)

    The ActiveFedora model class to be converter to json

  • converter_class (Class)

    The class that will convert from ActiveFedora to json

Raises:



19
20
21
22
23
# File 'lib/galter_ir_exporter/export/actor.rb', line 19

def register_converter(model_class, converter_class)
  raise(RegistryError, "Model (#{model_class.name}) for conversion must be an ActiveFedora::Base") unless model_class.ancestors.include?(ActiveFedora::Base)
  raise(RegistryError, "Converter (#{converter_class.name}) for conversion must be an GalterIrExporter::Export::Converter") unless converter_class.ancestors.include?(GalterIrExporter::Export::Converter)
  converter_registry[model_class] = converter_class
end