Sha256: d754ca96979e097e6acccf6da030abbdfbe7191fb1fdfaa461a43c43d39090ca

Contents?: true

Size: 842 Bytes

Versions: 16

Compression:

Stored size: 842 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Plans
    # The Tracer class allows performing PaperTrail requests where all records
    # saved during the yield will be stored against the same transaction ID.
    # This allows saving the main record and its associated records so that the
    # same changeset can be easily identified afterwards.
    class Tracer
      def trace!(author)
        return unless block_given?

        ::PaperTrail.request(whodunnit: gid(author)) do
          yield
        end
      end

      private

      # Calculates the GlobalID of the version author. If the object does not
      # respond to `to_gid`, then it returns the object itself.
      def gid(author)
        return if author.blank?
        return author.to_gid if author.respond_to?(:to_gid)
        author
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
decidim-plans-0.18.2 app/services/decidim/plans/tracer.rb
decidim-plans-0.18.1 app/services/decidim/plans/tracer.rb
decidim-plans-0.18.0 app/services/decidim/plans/tracer.rb
decidim-plans-0.17.0 app/services/decidim/plans/tracer.rb
decidim-plans-0.16.9 app/services/decidim/plans/tracer.rb
decidim-plans-0.16.8 app/services/decidim/plans/tracer.rb
decidim-plans-0.16.7 app/services/decidim/plans/tracer.rb
decidim-plans-0.16.6 app/services/decidim/plans/tracer.rb
decidim-plans-0.16.5 app/services/decidim/plans/tracer.rb
decidim-plans-0.16.4 app/services/decidim/plans/tracer.rb
decidim-plans-0.16.3 app/services/decidim/plans/tracer.rb
decidim-plans-0.16.2 app/services/decidim/plans/tracer.rb
decidim-plans-0.16.1 app/services/decidim/plans/tracer.rb
decidim-plans-0.16.0 app/services/decidim/plans/tracer.rb
decidim-plans-0.15.1 app/services/decidim/plans/tracer.rb
decidim-plans-0.15.0 app/services/decidim/plans/tracer.rb