Module: BindingDumper::CoreExt::BindingExt
- Defined in:
- lib/binding_dumper/core_ext/binding_ext.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#data_to_dump ⇒ Hash
Returns all the data that represents a context (including context, local variables, file, line and method name).
-
#dump {|String| ... } ⇒ String
Dumps a binding and returns a dump.
-
#lvars_to_dump ⇒ Hash
Returns mapping { local variable name => local variable }.
Instance Method Details
#data_to_dump ⇒ Hash
Returns all the data that represents a context
(including context, local variables, file, line and method name)
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/binding_dumper/core_ext/binding_ext.rb', line 29 def data_to_dump context = eval('self') result = { context: context, method: eval('__method__'), file: eval('__FILE__'), line: eval('__LINE__'), lvars: lvars_to_dump } end |
#dump {|String| ... } ⇒ String
Dumps a binding and returns a dump
46 47 48 49 50 |
# File 'lib/binding_dumper/core_ext/binding_ext.rb', line 46 def dump(&block) dumped = UniversalDumper.dump(data_to_dump) block.call(dumped) if block_given? dumped end |
#lvars_to_dump ⇒ Hash
Returns mapping
{ local variable name => local variable }
18 19 20 21 22 |
# File 'lib/binding_dumper/core_ext/binding_ext.rb', line 18 def lvars_to_dump eval('local_variables').each_with_object({}) do |lvar_name, result| result[lvar_name] = eval(lvar_name.to_s) end end |