Sha256: bb3922c809d479f3ec8f60523dcb02e9aa7c64d2113c20a161aa8259f18dd619

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

class BCDD::Result::TransitionsRecord < ActiveRecord::Base
  self.table_name = 'bcdd_result_transitions'

  class Listener
    include ::BCDD::Result::Transitions::Listener

    def on_finish(transitions:)
      metadata = transitions[:metadata]
      root_name = transitions.dig(:records, 0, :root, :name) || 'Unknown'

      records = transitions[:records].map do |record|
        record.deep_transform_values do |value|
          value.is_a?(::BCDD::Process) ? value.class.name : value
        end
      end

      BCDD::Result::TransitionsRecord.create(
        root_name: root_name,
        duration: metadata[:duration],
        trace_id: metadata[:trace_id],
        ids_tree: metadata[:ids_tree],
        ids_matrix: metadata[:ids_matrix],
        version: transitions[:version],
        records: records
      )
    rescue ::StandardError => e
      err = "#{e.message} (#{e.class}); Backtrace: #{e.backtrace.join(', ')}"

      ::Kernel.warn "Error on BCDD::Result::TransitionsRecord::Listener#on_finish: #{err}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bcdd-process-0.4.0 examples/business_processes/lib/bcdd/result/transitions_record.rb
bcdd-process-0.3.1 examples/business_processes/lib/bcdd/result/transitions_record.rb
bcdd-process-0.3.0 examples/business_processes/lib/bcdd/result/transitions_record.rb
bcdd-process-0.2.0 examples/business_processes/lib/bcdd/result/transitions_record.rb