Sha256: a6addda83bb3cff173603844ee276a7edb0bd92358ce811c213ac711b89774a2

Contents?: true

Size: 754 Bytes

Versions: 8

Compression:

Stored size: 754 Bytes

Contents

module WebConsole
  module Helper
    # Communicates with the middleware to render a console in a +binding+.
    #
    # If +bidning+ isn't explicitly given, Binding#of_caller will be used to
    # get the binding of the previous frame. E.g. the one that invoked
    # +console+.
    #
    # Raises DoubleRenderError if a double +console+ invocation per request is
    # detected.
    def console(binding = nil)
      raise DoubleRenderError if request.env['web_console.binding']

      request.env['web_console.binding'] = binding || ::Kernel.binding.of_caller(1)

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

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
web-console-2.3.0 lib/web_console/helper.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/web-console-2.2.1/lib/web_console/helper.rb
web-console-2.2.1 lib/web_console/helper.rb
web-console-2.2.0 lib/web_console/helper.rb
web-console-2.1.3 lib/web_console/helper.rb
web-console-2.1.2 lib/web_console/helper.rb
web-console-2.1.1 lib/web_console/helper.rb
web-console-2.1.0 lib/web_console/helper.rb