mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-06-17 01:18:36 +08:00
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
41 lines
659 B
Ruby
Vendored
41 lines
659 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
class Reviewable < ActiveRecord::Base
|
|
class Collection
|
|
class Item
|
|
include ActiveModel::Serialization
|
|
attr_reader :id
|
|
|
|
def initialize(id)
|
|
@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
|