Method: Referent#set_values_from_context_object

Defined in:
app/models/referent.rb

#set_values_from_context_object(co) ⇒ Object

Populate the referent_values table with a ropenurl contextobject object Note, does NOT save self, self may still be unsaved.



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'app/models/referent.rb', line 135

def set_values_from_context_object(co)
  rft = co.referent

  # Multiple identifiers are possible! 
  rft.identifiers.each do |id_string|
    build_referent_value('identifier', id_string)            
  end
  if rft.format
    build_referent_value('format', rft.format)
  end
  if rft.private_data
    # this comes in as "pid" or "rft_dat", we store it in
    # our database as "private_data", sorry, easiest way to
    # fit this in at the moment. 
    build_referent_value("private_data", rft.private_data)
  end
  
  rft..each { | key, value |
    next unless value.present?
    # Sometimes value is an array, for DC for instance. Do the best we
    # can. 
    Array(value).each do |v|
      build_referent_value( key, v)
    end
  }    
end