Class: Macros::Ctx::Inspect

Inherits:
Base
  • Object
show all
Defined in:
lib/macros/ctx/inspect.rb

Overview

Prints the entire tbl context or just a single resource

Examples:

prints the entire tbl context

step Macros::Ctx::Inspect()

prints the :model resource from the tbl context

step Macros::Ctx::Inspect(key: :model)

Instance Method Summary collapse

Methods inherited from Base

register

Constructor Details

#initialize(key: nil) ⇒ Macros::Debug::Ctx

Returns step macro instance.

Parameters:

  • key (Symbol or String) (defaults to: nil)

    ctx key under which is a resource to which we want to assign, optional



15
16
17
# File 'lib/macros/ctx/inspect.rb', line 15

def initialize(key: nil)
  @key = key
end

Instance Method Details

#call(ctx) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/macros/ctx/inspect.rb', line 19

def call(ctx, **)
  if @key
    p ctx[@key]
  else
    p ctx
  end
end