class WebConsole::Context
A context lets you get object names related to the current session binding.
Constants
- GLOBAL_OBJECTS
Public Class Methods
new(binding)
click to toggle source
# File lib/web_console/context.rb, line 4 def initialize(binding) @binding = binding end
Public Instance Methods
extract(input = nil)
click to toggle source
Extracts entire objects which can be called by the current session unless the inputs is present.
Otherwise, it extracts methods and constants of the object specified by the input.
# File lib/web_console/context.rb, line 13 def extract(input = nil) input.present? ? local(input) : global end
Private Instance Methods
eval(cmd)
click to toggle source
# File lib/web_console/context.rb, line 39 def eval(cmd) @binding.eval(cmd) rescue [] end
global()
click to toggle source
# File lib/web_console/context.rb, line 28 def global GLOBAL_OBJECTS.map { |cmd| eval(cmd) } end
local(input)
click to toggle source
# File lib/web_console/context.rb, line 32 def local(input) [ eval("#{input}.methods").map { |m| "#{input}.#{m}" }, eval("#{input}.constants").map { |c| "#{input}::#{c}" }, ] end