Sha256: 91eb701776c4542a7fe33d906b8f16982dc2ca9ba558a5f0dd61fa6d3c54d942

Contents?: true

Size: 484 Bytes

Versions: 1

Compression:

Stored size: 484 Bytes

Contents

class Bidu::House::Report::Multiple < Bidu::House::Report
  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.2.0 lib/bidu/house/report/multiple.rb