Sha256: 17b15cbef6d709b75eed854d988b24373a8eeeff05449ca2c5bc0b623eea769e

Contents?: true

Size: 457 Bytes

Versions: 2

Compression:

Stored size: 457 Bytes

Contents

module 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 & 1 rubygems

Version Path
mercy-1.6.0 lib/mercy/report/multiple.rb
mercy-1.5.0 lib/mercy/report/multiple.rb