Class: ApiMaker::PreloaderHasMany
- Inherits:
-
Object
- Object
- ApiMaker::PreloaderHasMany
- Defined in:
- lib/api_maker/preloader_has_many.rb
Instance Method Summary collapse
-
#initialize(ability:, args:, data:, collection:, reflection:, records:, select:) ⇒ PreloaderHasMany
constructor
A new instance of PreloaderHasMany.
- #preload ⇒ Object
Constructor Details
#initialize(ability:, args:, data:, collection:, reflection:, records:, select:) ⇒ PreloaderHasMany
Returns a new instance of PreloaderHasMany.
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/api_maker/preloader_has_many.rb', line 2 def initialize(ability:, args:, data:, collection:, reflection:, records:, select:) @ability = ability @args = args @data = data @collection = collection @reflection = reflection @records = records @select = select raise "No inverse of for #{@reflection.active_record.name}##{@reflection.name}" unless @reflection.inverse_of end |
Instance Method Details
#preload ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/api_maker/preloader_has_many.rb', line 14 def preload models.each do |model| preload_model(model) end {collection: models} end |