Sha256: b5b32c9ab74c56d95e945b03b6f7df3f2aba874ab8345bb9e8fd8a6c779eb2b0

Contents?: true

Size: 775 Bytes

Versions: 1

Compression:

Stored size: 775 Bytes

Contents

# frozen_string_literal: true

module Macros
  class Ctx
    # Prints the entire tbl context or just a single resource
    #
    # @example prints the entire tbl context
    #   step Macros::Ctx::Inspect()
    #
    # @example prints the :model resource from the tbl context
    #   step Macros::Ctx::Inspect(key: :model)
    class Inspect < Macros::Base
      # @return [Macros::Debug::Ctx] step macro instance
      # @param key [Symbol or String] ctx key under which is a resource to which we want to assign, optional
      def initialize(key: nil)
        @key = key
      end

      def call(ctx, **)
        if @key
          p ctx[@key] # rubocop:disable Rails/Output
        else
          p ctx # rubocop:disable Rails/Output
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ff-tbl-macros-1.0.0 lib/macros/ctx/inspect.rb