Sha256: da3809083c696d3bd3802ad6fefdc0eba2c6b14da5cb038fab8d702bf8abf68a

Contents?: true

Size: 463 Bytes

Versions: 1

Compression:

Stored size: 463 Bytes

Contents

module Bidu::House::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

1 entries across 1 versions & 1 rubygems

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