Sha256: 1e52ba089649e89832e01494f67b2261af8d8e80dd29e9f1c410f0e742d5f7ff

Contents?: true

Size: 1.14 KB

Versions: 77

Compression:

Stored size: 1.14 KB

Contents

module Ddr
  module Datastreams
    class MetadataDatastream < ActiveFedora::NtriplesRDFDatastream

      def self.term_names
        properties.keys.map(&:to_sym).sort
      end

      # Returns ActiveTriplesTerm now that this is an RDF datastream
      def values term
        term == :format ? self.format : self.send(term)
      end

      # Update term with values
      # Note that empty values (nil or "") are rejected from values array
      def set_values term, values
        if values.respond_to?(:reject!)
          values.reject! { |v| v.blank? }
        else
          values = nil if values.blank?
        end
        begin
          self.send("#{term}=", values)
        rescue NoMethodError
          raise ArgumentError, "No such term: #{term}"
        end
      end

      # Add value to term
      # Note that empty value (nil or "") is not added
      def add_value term, value
        begin
          unless value.blank?
            values = values(term).to_a << value
            set_values term, values
          end
        rescue NoMethodError
          raise ArgumentError, "No such term: #{term}"
        end
      end

    end
  end
end

Version data entries

77 entries across 77 versions & 1 rubygems

Version Path
ddr-models-2.6.2 lib/ddr/datastreams/metadata_datastream.rb
ddr-models-2.6.1 lib/ddr/datastreams/metadata_datastream.rb
ddr-models-2.6.0 lib/ddr/datastreams/metadata_datastream.rb
ddr-models-2.6.0.rc4 lib/ddr/datastreams/metadata_datastream.rb
ddr-models-2.6.0.rc3 lib/ddr/datastreams/metadata_datastream.rb
ddr-models-2.6.0.rc2 lib/ddr/datastreams/metadata_datastream.rb
ddr-models-2.6.0.rc1 lib/ddr/datastreams/metadata_datastream.rb
ddr-models-2.5.3 lib/ddr/datastreams/metadata_datastream.rb
ddr-models-2.5.2 lib/ddr/datastreams/metadata_datastream.rb
ddr-models-2.5.1 lib/ddr/datastreams/metadata_datastream.rb
ddr-models-2.5.0 lib/ddr/datastreams/metadata_datastream.rb
ddr-models-2.5.0.rc1 lib/ddr/datastreams/metadata_datastream.rb
ddr-models-2.4.16 lib/ddr/datastreams/metadata_datastream.rb
ddr-models-2.4.15 lib/ddr/datastreams/metadata_datastream.rb
ddr-models-2.4.14 lib/ddr/datastreams/metadata_datastream.rb
ddr-models-2.4.13 lib/ddr/datastreams/metadata_datastream.rb
ddr-models-2.4.12 lib/ddr/datastreams/metadata_datastream.rb
ddr-models-2.4.11 lib/ddr/datastreams/metadata_datastream.rb
ddr-models-2.4.10 lib/ddr/datastreams/metadata_datastream.rb
ddr-models-2.4.9 lib/ddr/datastreams/metadata_datastream.rb