Sha256: fde494d873a7878e35f215a1cfe4aa27f53822d188c5b328f235249442ec7072
Contents?: true
Size: 1.26 KB
Versions: 47
Compression:
Stored size: 1.26 KB
Contents
module ActiveFedora module Associations class BelongsToAssociation < AssociationProxy #:nodoc: def create(attributes = {}) replace(@reflection.create_association(attributes)) end def build(attributes = {}) replace(@reflection.build_association(attributes)) end def replace(record) if record.nil? @owner.clear_relationship(@reflection.options[:property]) else raise_on_type_mismatch(record) @owner.clear_relationship(@reflection.options[:property]) @target = (AssociationProxy === record ? record.target : record) @owner.add_relationship(@reflection.options[:property], record) unless record.new_record? @updated = true end loaded record end private def find_target pid = @owner.ids_for_outbound(@reflection.options[:property]).first return if pid.nil? query = ActiveFedora::SolrService.construct_query_for_pids([pid]) solr_result = SolrService.query(query) return ActiveFedora::SolrService.reify_solr_results(solr_result).first end def foreign_key_present !@owner.send(@reflection.primary_key_name).nil? end end end end
Version data entries
47 entries across 47 versions & 1 rubygems