Sha256: c9019232c532bd66e4b9ef8d7f5f8ddd43113b4af9de73cc235f265ea27d355c

Contents?: true

Size: 463 Bytes

Versions: 2

Compression:

Stored size: 463 Bytes

Contents

module Bidu::Mercy::Report::Multiple
  def as_json
    {
      status: status
    }.merge(sub_reports_hash)
  end

  def error?
    sub_reports.any?(&:error?)
  end

  private

  def sub_reports_hash
    sub_reports.map(&:as_json).as_hash(reports_ids.map(&:to_s))
  end

  def sub_reports
    @sub_reports ||= reports_ids.map do |id|
      build_sub_report(id)
    end
  end

  def build_sub_report(id)
    sub_report_class.new(json.merge(key => id))
  end
end


Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
mercy-1.3.0 lib/bidu/mercy/report/multiple.rb
bidu-mercy-1.3.0 lib/bidu/mercy/report/multiple.rb