Class: ActiveFedora::Associations::BelongsToAssociation
- Inherits:
-
AssociationProxy
- Object
- AssociationProxy
- ActiveFedora::Associations::BelongsToAssociation
- Defined in:
- lib/active_fedora/associations/belongs_to_association.rb
Overview
:nodoc:
Instance Method Summary collapse
Methods inherited from AssociationProxy
#initialize, #loaded, #loaded?, #reload, #reset, #target, #target=
Constructor Details
This class inherits a constructor from ActiveFedora::Associations::AssociationProxy
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ActiveFedora::Associations::AssociationProxy
Instance Method Details
#replace(record) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/active_fedora/associations/belongs_to_association.rb', line 4 def replace(record) if record.nil? ### TODO a more efficient way of doing this would be to write a clear_relationship method old_record = find_target @owner.remove_relationship(@reflection.[:property], old_record) unless old_record.nil? else raise_on_type_mismatch(record) ### TODO a more efficient way of doing this would be to write a clear_relationship method old_record = find_target @owner.remove_relationship(@reflection.[:property], old_record) unless old_record.nil? @target = (AssociationProxy === record ? record.target : record) @owner.add_relationship(@reflection.[:property], record) unless record.new_record? @updated = true end loaded record end |