Class: Uchi::Field::HasMany::Show
Instance Attribute Summary
#field, #record, #repository
Instance Method Summary
collapse
#initialize, #value
Instance Method Details
#associated_records ⇒ Object
61
62
63
64
65
|
# File 'app/components/uchi/field/has_many.rb', line 61
def associated_records
records = field.value(record)
associated_repository.find_all(scope: records)
end
|
#associated_repository ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'app/components/uchi/field/has_many.rb', line 67
def associated_repository
raise NameError, "No association named #{field.name.inspect} found on #{record.class}" unless reflection
associated_model = reflection.klass
repository_class = Uchi::Repository.for_model(associated_model)
unless repository_class
raise \
NameError,
"No repository found for associated model #{associated_model}"
end
repository_class.new
end
|