Sha256: 1aed0da8d7beb00578b06436477ed7b7676341f43f746c0d134deae0c48184ce

Contents?: true

Size: 986 Bytes

Versions: 12

Compression:

Stored size: 986 Bytes

Contents

require "forwardable"

module Ddr::Models
  class DescriptiveMetadata
    extend Forwardable
    include Metadata

    class_attribute :mappings

    class << self
      def mapping
        @mapping ||= mappings.reduce(&:merge)
      end

      def unqualified_names
        mapping.unqualified_names
      end

      def field_names
        mapping.keys
      end
      alias_method :field_readers, :field_names

      def field_writers
        field_names.map { |name| "#{name}=".to_sym }
      end
    end

    self.mappings = [ MetadataMapping.dcterms, MetadataMapping.duketerms ].freeze

    attr_reader :object

    def_delegators :object, *field_readers
    def_delegators :object, *field_writers

    mapping.each do |qualified_name, term|
      def_delegator :object, qualified_name, term.unqualified_name
      def_delegator :object, "#{qualified_name}=".to_sym, "#{term.unqualified_name}=".to_sym
    end

    def initialize(object)
      @object = object
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ddr-models-3.0.0.beta.11 lib/ddr/models/metadata/descriptive_metadata.rb
ddr-models-3.0.0.beta.10 lib/ddr/models/metadata/descriptive_metadata.rb
ddr-models-3.0.0.beta.9 lib/ddr/models/metadata/descriptive_metadata.rb
ddr-models-3.0.0.beta.8 lib/ddr/models/metadata/descriptive_metadata.rb
ddr-models-3.0.0.beta.7 lib/ddr/models/metadata/descriptive_metadata.rb
ddr-models-3.0.0.beta.6 lib/ddr/models/metadata/descriptive_metadata.rb
ddr-models-3.0.0.beta.4 lib/ddr/models/metadata/descriptive_metadata.rb
ddr-models-3.0.0.beta.3 lib/ddr/models/metadata/descriptive_metadata.rb
ddr-models-3.0.0.beta.2 lib/ddr/models/metadata/descriptive_metadata.rb
ddr-models-3.0.0.beta.1 lib/ddr/models/metadata/descriptive_metadata.rb
ddr-models-3.0.0.alpha.4 lib/ddr/models/metadata/descriptive_metadata.rb
ddr-models-3.0.0.alpha.3 lib/ddr/models/metadata/descriptive_metadata.rb