tag_relationships_presenter.rb 487 B

12345678910111213
  1. # frozen_string_literal: true
  2. class TagRelationshipsPresenter
  3. attr_reader :following_map
  4. def initialize(tags, current_account_id = nil, **options)
  5. @following_map = if current_account_id.nil?
  6. {}
  7. else
  8. TagFollow.select(:tag_id).where(tag_id: tags.map(&:id), account_id: current_account_id).each_with_object({}) { |f, h| h[f.tag_id] = true }.merge(options[:following_map] || {})
  9. end
  10. end
  11. end