2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-01-03 12:03:01 -05:00
|
|
|
class Reviewable < ActiveRecord::Base
|
|
|
|
class Collection
|
|
|
|
class Item
|
|
|
|
include ActiveModel::Serialization
|
2022-03-21 15:32:47 -04:00
|
|
|
attr_reader :id
|
2019-01-03 12:03:01 -05:00
|
|
|
|
2022-03-21 15:32:47 -04:00
|
|
|
def initialize(id)
|
2019-01-03 12:03:01 -05:00
|
|
|
@id = id
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize(reviewable, guardian, args = nil)
|
|
|
|
args ||= {}
|
|
|
|
|
|
|
|
@reviewable, @guardian, @args = reviewable, guardian, args
|
|
|
|
@content = []
|
|
|
|
end
|
|
|
|
|
|
|
|
def has?(id)
|
|
|
|
@content.any? { |a| a.id.to_s == id.to_s }
|
|
|
|
end
|
|
|
|
|
|
|
|
def blank?
|
|
|
|
@content.blank?
|
|
|
|
end
|
|
|
|
|
|
|
|
def present?
|
|
|
|
!blank?
|
|
|
|
end
|
|
|
|
|
|
|
|
def each
|
|
|
|
@content.each { |i| yield i }
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_a
|
|
|
|
@content
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|