mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-03 22:38:10 +08:00
35 lines
646 B
Ruby
35 lines
646 B
Ruby
# 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
|
|
|
|
delegate :present?, :blank?, to: :@content
|
|
|
|
def initialize(reviewable, guardian, args = nil)
|
|
args ||= {}
|
|
|
|
@reviewable, @guardian, @args = reviewable, guardian, args
|
|
@content = []
|
|
end
|
|
|
|
def has?(action_id)
|
|
@content.any? { |a| a.server_action.to_s == action_id.to_s }
|
|
end
|
|
|
|
def each
|
|
@content.each { |i| yield i }
|
|
end
|
|
|
|
def to_a
|
|
@content
|
|
end
|
|
end
|
|
end
|