Sha256: de634562593f6bf3968c23d2c16f7cd6489182fe2197d501de5ba532bfa9bcb3

Contents?: true

Size: 713 Bytes

Versions: 6

Compression:

Stored size: 713 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]
        else
          p ctx
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ff-tbl-macros-2.0.2 lib/macros/ctx/inspect.rb
ff-tbl-macros-2.0.1 lib/macros/ctx/inspect.rb
ff-tbl-macros-2.0.0 lib/macros/ctx/inspect.rb
ff-tbl-macros-1.0.2 lib/macros/ctx/inspect.rb
ff-tbl-macros-1.0.1 lib/macros/ctx/inspect.rb
ff-tbl-macros-0.1.8 lib/macros/ctx/inspect.rb