11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/identity_cache/belongs_to_caching.rb', line 11
def cache_belongs_to(association, options = {})
ensure_base_model
raise NotImplementedError if options[:embed]
unless association_reflection = reflect_on_association(association)
raise AssociationError, "Association named '#{association}' was not found on #{self.class}"
end
options = {}
self.cached_belongs_tos[association] = options
options[:embed] = false
options[:cached_accessor_name] = "fetch_#{association}"
options[:records_variable_name] = "cached_#{association}"
options[:association_reflection] = association_reflection
options[:prepopulate_method_name] = "prepopulate_fetched_#{association}"
build_normalized_belongs_to_cache(association, options)
end
|