discourse/lib/reviewable/collection.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
706 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class Reviewable < ActiveRecord::Base
class Collection
class Item
include ActiveModel::Serialization
attr_reader :id, :reason
def initialize(id, reason: nil)
@id = id
@reason = reason
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