エピソードの公開設定 # 公開設定 class PublishingSetting < ApplicationRecord ## typeによってどの公開設定化を判別する def free? type == 'PublishingSetting::Free' end def sell? type == 'PublishingSetting::Sell' end end
購入情報を一括で取得する class Story < ApplicationRecord #... bulk_loader, :purchased? do |ids, user_id| next {} if user_id.nil? # APIで購入の有無を問い合わせ purchased_story_ids = Store::App::OrderedEpisodes.get(user_id, ids) # {id => purchased?} という形式のHashに変換 ids.index_with {|id| purchased_story_ids.include?(id) } end end