Sha256: d8798330c43cf915bdb896d6c153b4ea5840026b4facd14fdf70980479905332

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

module RelatonUn
  module HashConverter
    include RelatonBib::HashConverter
    extend self
    # @override RelatonIsoBib::HashConverter.hash_to_bib
    # @param args [Hash]
    # @param nested [TrueClass, FalseClass]
    # @return [Hash]
    def hash_to_bib(args)
      ret = super
      return if ret.nil?

      hash_to_bib_submissions ret
      session_hash_to_bib ret
      ret[:distribution] = ret[:ext][:distribution] if ret.dig(:ext, :distribution)
      ret[:job_number] = ret[:ext][:job_number] if ret.dig(:ext, :job_number)
      ret
    end

    private

    def hash_to_bib_submissions(ret)
      sm = ret.dig(:ext, :submissionlanguage) || ret[:submissionlanguage] # @TODO remove args[:submissionlanguage] after all gems are updated
      return unless sm

      ret[:submissionlanguage] = RelatonBib.array sm
    end

    # @param ret [Hash]
    def session_hash_to_bib(ret)
      session = ret.dig(:ext, :session) || ret[:session] # @TODO remove ret[:session] after all gems are updated
      return unless session

      ret[:session] = Session.new(**session)
    end

    # @param ret [Hash]
    def editorialgroup_hash_to_bib(ret)
      eg = ret.dig(:ext, :editorialgroup) || ret[:editorialgroup] # @TODO remove ret[:editorialgroup] after all gems are updated
      return unless eg

      committee = eg.map { |e| e[:committee] }
      ret[:editorialgroup] = EditorialGroup.new RelatonBib.array(committee)
    end

    def create_doctype(**args)
      DocumentType.new(**args)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
relaton-un-1.20.0 lib/relaton_un/hash_converter.rb