Class: ActiveFedora::Associations::BelongsToAssociation

Inherits:
SingularAssociation show all
Defined in:
lib/active_fedora/associations/belongs_to_association.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Association

#inversed, #owner, #reflection, #target

Instance Method Summary collapse

Methods inherited from SingularAssociation

#build, #create, #create!, #reader, #writer

Methods inherited from Association

#association_scope, #initialize, #initialize_attributes, #load_target, #loaded!, #loaded?, #reload, #scope, #set_inverse_instance, #stale_target?, #target_scope

Constructor Details

This class inherits a constructor from ActiveFedora::Associations::Association

Instance Method Details

#replace(record) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/active_fedora/associations/belongs_to_association.rb', line 5

def replace(record)
  if record
    raise_on_type_mismatch(record)
    # update_counters(record)
    replace_keys(record)
    set_inverse_instance(record)
    @updated = true
  else
    # decrement_counters
    remove_keys
  end

  self.target = record
end

#resetObject


20
21
22
23
# File 'lib/active_fedora/associations/belongs_to_association.rb', line 20

def reset
  super
  @updated = false
end

#updated?Boolean

Returns:

  • (Boolean)

25
26
27
# File 'lib/active_fedora/associations/belongs_to_association.rb', line 25

def updated?
  @updated
end