Sha256: f34893dac7c616134536d0ce752ba49fa7918637e3bb735e01302efc018bed7e

Contents?: true

Size: 756 Bytes

Versions: 7

Compression:

Stored size: 756 Bytes

Contents

# frozen_string_literal: true

require_relative 'schema/loader'
require_relative 'builder/report_builder'

module Thinreports
  module SectionReport
    class Build
      def call(report_params)
        schema = load_schema(report_params)
        params = report_params[:params] || {}

        Builder::ReportBuilder.new(schema).build(params)
      end

      private

      def load_schema(report_params)
        loader = Schema::Loader.new

        case
        when report_params[:layout_file]
          loader.load_from_file(report_params[:layout_file])
        when report_params[:layout_data]
          loader.load_from_data(report_params[:layout_data])
        else
          raise Errors::LayoutFileNotFound
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
thinreports-0.14.2 lib/thinreports/section_report/build.rb
thinreports-0.14.1 lib/thinreports/section_report/build.rb
thinreports-0.14.0 lib/thinreports/section_report/build.rb
thinreports-0.13.1 lib/thinreports/section_report/build.rb
thinreports-0.13.0 lib/thinreports/section_report/build.rb
thinreports-0.12.1 lib/thinreports/section_report/build.rb
thinreports-0.12.0 lib/thinreports/section_report/build.rb