Sha256: 161720be93b93515008f515deb58d958db3cef1f6bce811df5318dce36c1f429
Contents?: true
Size: 1.13 KB
Versions: 25
Compression:
Stored size: 1.13 KB
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 def property_terms mapping.terms.each_with_object({}) do |term, memo| memo[term.unqualified_name] = term.qualified_name end 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
25 entries across 25 versions & 1 rubygems