Class: ActiveFedora::Associations::BelongsToAssociation
Overview
Instance Attribute Summary
Attributes inherited from Association
#owner, #reflection, #target
Instance Method Summary
collapse
#build, #create, #create!, #reader, #writer
Methods inherited from Association
#association_scope, #initialize, #load_target, #loaded!, #loaded?, #reload, #scope, #set_inverse_instance, #stale_target?, #target_scope
Instance Method Details
#id_reader ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/active_fedora/associations/belongs_to_association.rb', line 12
def id_reader
@full_result ||= begin
ids = @owner.ids_for_outbound(@reflection.options[:property])
return if ids.empty?
results = SolrService.query(construct_query(ids))
if results.present?
results.first
end
end
@full_result['id'] if @full_result
end
|
#replace(record) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/active_fedora/associations/belongs_to_association.rb', line 31
def replace(record)
if record.nil?
id_writer(nil)
else
raise_on_type_mismatch(record)
id_writer(record.id)
@updated = true
end
self.target = record
loaded!
record
end
|
#reset ⇒ Object
47
48
49
50
|
# File 'lib/active_fedora/associations/belongs_to_association.rb', line 47
def reset
super
@updated = false
end
|
#updated? ⇒ Boolean
52
53
54
|
# File 'lib/active_fedora/associations/belongs_to_association.rb', line 52
def updated?
@updated
end
|