Class: ActiveFedora::OmAttribute

Inherits:
StreamAttribute show all
Defined in:
lib/active_fedora/attributes/om_attribute.rb

Overview

Class for attributes that are delegated to an OmDatastream

Instance Attribute Summary

Attributes inherited from StreamAttribute

#at, #delegate_target, #target_class

Attributes inherited from DelegatedAttribute

#field, #multiple

Instance Method Summary collapse

Methods inherited from StreamAttribute

#initialize, #primary_solr_name, #type

Methods inherited from DelegatedAttribute

#initialize

Constructor Details

This class inherits a constructor from ActiveFedora::StreamAttribute

Instance Method Details

#reader(obj, *opts) ⇒ Object

Parameters:

  • obj (ActiveFedora::Base)

    the object that has the attribute

  • opts (Object)

    extra options that are passed to the target reader



18
19
20
21
22
23
24
25
26
# File 'lib/active_fedora/attributes/om_attribute.rb', line 18

def reader(obj, *opts)
  ds = file_for_attribute(obj, delegate_target)
  terminology = at || [field]
  if terminology.length == 1 && opts.present?
    ds.send(terminology.first, *opts)
  else
    ds.send(:term_values, *terminology)
  end
end

#writer(obj, v) ⇒ Object

Parameters:

  • obj (ActiveFedora::Base)

    the object that has the attribute

  • v (Object)

    value to write to the attribute



9
10
11
12
13
14
# File 'lib/active_fedora/attributes/om_attribute.rb', line 9

def writer(obj, v)
  ds = file_for_attribute(obj, delegate_target)
  obj.mark_as_changed(field) if obj.value_has_changed?(field, v)
  terminology = at || [field]
  ds.send(:update_indexed_attributes, {terminology => v})
end