class Libis::Ingester::IngestModel

Public Class Methods

from_hash(hash) click to toggle source
# File lib/libis/ingester/ingest_model.rb, line 37
def self.from_hash(hash)
  # noinspection RubyResolve
  self.create_from_hash(hash, [:name]) do |item, cfg|
    item.access_right = Libis::Ingester::AccessRight.from_hash(name: cfg.delete('access_right'))
    item.retention_period = Libis::Ingester::RetentionPeriod.from_hash(name: cfg.delete('retention_period'))
    item.manifestations.clear
    (cfg.delete('manifestations') || []).each do |mf_cfg|
      item.manifestations << Libis::Ingester::Manifestation.from_hash(mf_cfg)
    end
  end
end

Public Instance Methods

to_hash() click to toggle source

noinspection RubyResolve

Calls superclass method
# File lib/libis/ingester/ingest_model.rb, line 50
def to_hash
  result = super
  result[:access_right_id] = self.access_right.ar_id if self.access_right
  result[:retention_period_id] = self.retention_period.rp_id if self.retention_period
  result[:manifestations] = self.manifestations.map(&:to_hash)
  result.cleanup
end