class ActiveFedora::MetadataDatastream
def field(name, tupe, opts={})
you will end up replicating the values in the underlying datastream, resulting in mysterious dubling, quadrupling, etc.
!! Careful: If you declare two fields that correspond to the same xml node without any qualifiers to differentiate them,
There is quite a good example of this class in use in spec/examples/oral_history.rb
At some point, these modifiers will be ported up to work for any +ActiveFedora::MetadataDatastream+.
:multiple=>true - mark this field as a multivalue field (on by default)
:encoding=>foo, or encodings_scheme - causes an xsi:type attribute to be set to 'foo'
:xml_node => :nodename - The xml node to be used to represent this object (in dcterms namespace)
:element_attrs =>{:foo=>:bar} - hash of xml element attributes
For +QualifiedDublinCorDatastreams+:
Currently supported modifiers:
opts is an options hash, which will affect the generation of the xml representation of this datastream.
'tupe' is a datatype, currently :string, :text and :date are supported.
Calling any of the generated methods marks self as dirty.
name_append(arg)
name_values
name_values=(arg)
each field will have the 3 magic methods:
This method generates the various accessor and mutator methods on self for the datastream metadata attributes.
def field(name, tupe, opts={}) @fields[name.to_s.to_sym]={:type=>tupe, :values=>[]}.merge(opts) eval <<-EOS def #{name}_values=(arg) @fields["#{name.to_s}".to_sym][:values]=[arg].flatten self.dirty=true end def #{name}_values @fields["#{name}".to_sym][:values] end def #{name}_append(arg) @fields["#{name}".to_sym][:values] << arg self.dirty =true end EOS end