Sha256: 443315ed2945cc0e79f95db3d22e94181ccc95c4f1c094f3a6fe6670d4a71042

Contents?: true

Size: 1.32 KB

Versions: 21

Compression:

Stored size: 1.32 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

21 entries across 21 versions & 1 rubygems

Version Path
active-fedora-9.7.3 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.7.2 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.13.0 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.12.0 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.11.0 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.10.4 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.10.3 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.10.2 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.10.1 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.10.0 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.10.0.pre2 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.10.0.pre1 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.9.1 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.9.0 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.8.2 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.8.1 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.8.0 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.7.1 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.7.0 lib/active_fedora/attributes/rdf_datastream_attribute.rb
active-fedora-9.6.2 lib/active_fedora/attributes/rdf_datastream_attribute.rb