Sha256: ef3107ef7aa4196b9988422948b3cd41a6b57cdf730061b2e587111a8c4c42b8

Contents?: true

Size: 917 Bytes

Versions: 37

Compression:

Stored size: 917 Bytes

Contents

module Ddr::Models
  class MetadataMapping < SimpleDelegator

    class << self
      def build(vocab, label=nil)
        mapping = vocab.terms.each_with_object({}) do |term, memo|
          memo[term.qualified_name] = term
        end
        new(mapping, label)
      end

      def dc11
        @dc11 ||= build(MetadataVocabulary.dc11, "DC Elements").freeze
      end

      def dcterms
        @dcterms ||= build(MetadataVocabulary.dcterms, "DC Terms").freeze
      end

      def duketerms
        @duketerms ||= build(MetadataVocabulary.duketerms, "Duke Terms").freeze
      end
    end

    attr_accessor :label

    def initialize(mapping=Hash.new, label=nil)
      super(mapping)
      @label = label
    end

    def terms
      values
    end

    def unqualified_names
      terms.map(&:unqualified_name)
    end

    def merge(other)
      MetadataMapping.new(__getobj__.merge(other))
    end

  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
ddr-models-3.0.8 lib/ddr/models/metadata/metadata_mapping.rb
ddr-models-3.0.7 lib/ddr/models/metadata/metadata_mapping.rb
ddr-models-3.0.6 lib/ddr/models/metadata/metadata_mapping.rb
ddr-models-3.0.5 lib/ddr/models/metadata/metadata_mapping.rb
ddr-models-3.0.4 lib/ddr/models/metadata/metadata_mapping.rb
ddr-models-3.0.3 lib/ddr/models/metadata/metadata_mapping.rb
ddr-models-3.0.2 lib/ddr/models/metadata/metadata_mapping.rb
ddr-models-3.0.1 lib/ddr/models/metadata/metadata_mapping.rb
ddr-models-3.0.0 lib/ddr/models/metadata/metadata_mapping.rb
ddr-models-3.0.0.rc6 lib/ddr/models/metadata/metadata_mapping.rb
ddr-models-3.0.0.rc5 lib/ddr/models/metadata/metadata_mapping.rb
ddr-models-3.0.0.rc4 lib/ddr/models/metadata/metadata_mapping.rb
ddr-models-3.0.0.rc3 lib/ddr/models/metadata/metadata_mapping.rb
ddr-models-3.0.0.rc2 lib/ddr/models/metadata/metadata_mapping.rb
ddr-models-3.0.0.rc1 lib/ddr/models/metadata/metadata_mapping.rb
ddr-models-3.0.0.beta.22 lib/ddr/models/metadata/metadata_mapping.rb
ddr-models-3.0.0.beta.21 lib/ddr/models/metadata/metadata_mapping.rb
ddr-models-3.0.0.beta.20 lib/ddr/models/metadata/metadata_mapping.rb
ddr-models-3.0.0.beta.18 lib/ddr/models/metadata/metadata_mapping.rb
ddr-models-3.0.0.beta.17 lib/ddr/models/metadata/metadata_mapping.rb