Sha256: 2a04ebc0db9c3dc231d9b08f6b083e10b76a5f754a606d6abbb04c989cae55a7

Contents?: true

Size: 1.14 KB

Versions: 10

Compression:

Stored size: 1.14 KB

Contents

module ActiveFedora

  # Class for attributes that are delegated to a RDFDatastream

  class RdfDatastreamAttribute < StreamAttribute

    # @param [ActiveFedora::Base] obj the object that has the attribute
    # @param [Object] v value to write to the attribute
    def writer(obj, v)
      node = file_for_attribute(obj, delegate_target)
      obj.mark_as_changed(field) if obj.value_has_changed?(field, v)
      term = if at
        vals = at.dup
        while vals.length > 1
          node = node.send(vals.shift)
          node = node.build if node.empty?
          node = node.first
        end
        vals.first
      else
        field
      end
      node.send("#{term}=", v)
    end

    # @param [ActiveFedora::Base] obj the object that has the attribute
    def reader(obj)
      node = file_for_attribute(obj, delegate_target)
      term = if at
        vals = at.dup
        while vals.length > 1
          node = node.send(vals.shift)
          node = if node.empty?
            node.build
          else
            node.first
          end
        end
        vals.first
      else
        field
      end
      node.send(term)
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
active-fedora-9.5.0 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.4.3 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.4.2 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.4.1 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.4.0 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.3.0 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.2.1 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.2.0 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.2.0.rc2 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.2.0.rc1 lib/active_fedora/attributes/rdf_datastream_attribute.rb