class WebConsole::Context
A context lets you get object names related to the current session binding.
Constants
- GLOBAL_OBJECTS
Public Class Methods
Source
# File lib/web_console/context.rb, line 6 def initialize(binding) @binding = binding end
Public Instance Methods
Source
# File lib/web_console/context.rb, line 15 def extract(input = nil) input.present? ? local(input) : global end
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.
Private Instance Methods
Source
# File lib/web_console/context.rb, line 41 def eval(cmd) @binding.eval(cmd) rescue [] end
Source
# File lib/web_console/context.rb, line 30 def global GLOBAL_OBJECTS.map { |cmd| eval(cmd) } end
Source
# File lib/web_console/context.rb, line 34 def local(input) [ eval("#{input}.methods").map { |m| "#{input}.#{m}" }, eval("#{input}.constants").map { |c| "#{input}::#{c}" }, ] end