Sha256: 165927f8031602cffa402a15748beefb4e8179789b3c147d093a7cf085be34be

Contents?: true

Size: 1 KB

Versions: 11

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module Kernel
  module_function

  # Instructs Web Console to render a console in the specified binding.
  #
  # If +binding+ isn't explicitly given it will default to the binding of the
  # previous frame. E.g. the one that invoked +console+.
  #
  # Raises +DoubleRenderError+ if a more than one +console+ invocation per
  # request is detected.
  def console(binding = Bindex.current_bindings.second)
    raise WebConsole::DoubleRenderError if Thread.current[:__web_console_binding]

    Thread.current[:__web_console_binding] = binding

    # Make sure nothing is rendered from the view helper. Otherwise
    # you're gonna see unexpected #<Binding:0x007fee4302b078> in the
    # templates.
    nil
  end
end

class Binding
  # Instructs Web Console to render a console in the current binding, without
  # the need to unroll the stack.
  #
  # Raises +DoubleRenderError+ if a more than one +console+ invocation per
  # request is detected.
  def console
    Kernel.console(self)
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/web-console-4.2.1/lib/web_console/extensions.rb
web-console-4.2.1 lib/web_console/extensions.rb
web-console-4.2.0 lib/web_console/extensions.rb
web-console-4.1.0 lib/web_console/extensions.rb
web-console-4.0.4 lib/web_console/extensions.rb
web-console-4.0.3 lib/web_console/extensions.rb
web-console-4.0.2 lib/web_console/extensions.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/web-console-4.0.1/lib/web_console/extensions.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/web-console-4.0.1/lib/web_console/extensions.rb
web-console-4.0.1 lib/web_console/extensions.rb
web-console-4.0.0 lib/web_console/extensions.rb