Files
growstuff/app/resources/photo_resource.rb
T
Brenda Wallace 1135c763de Tidy API resources: read_only and owned macros, private hook helpers
Declare read-only resources and the owner relationship once each, make
the resource hook helpers private, simplify token auth, and cache the
generated API docs for an hour.
2026-10-25 11:48:28 +13:00

20 lines
483 B
Ruby

# frozen_string_literal: true
class PhotoResource < ApplicationResource
self.model = Photo
read_only
attribute :thumbnail_url, :string
attribute :fullsize_url, :string
attribute :license_name, :string
attribute :link_url, :string
attribute :title, :string
filter :crop_id, :integer do
eq { |scope, ids| scope.where(id: PhotoAssociation.where(crop_id: ids).select(:photo_id)) }
end
owned
%w(Planting Garden Harvest).each { |type| photographed type }
end