class BindingDumper::Dumpers::Abstract
Class with common functionality of all dumpers
Attributes
dumped_ids[R]
Public Class Methods
new(abstract_object, dumped_ids = [])
click to toggle source
@param abstract_object
[Object] any object @param dumped_ids
[Array<Fixnum>] list of object ids that are already dumped
# File lib/binding_dumper/dumpers/abstract.rb, line 9 def initialize(abstract_object, dumped_ids = []) @abstract_object = abstract_object @dumped_ids = dumped_ids end
Private Instance Methods
abstract_object()
click to toggle source
Returns abstract object
Sometimes it's a Hash that represents object structure Sometimes it's just that object (if its' primitive)
@return [Object]
# File lib/binding_dumper/dumpers/abstract.rb, line 22 def abstract_object if @abstract_object.is_a?(Hash) && @abstract_object.has_key?(:_object_data) @abstract_object[:_object_data] else @abstract_object end end
can_be_dumped_as_copy?(object)
click to toggle source
Returns true
if undumpable object (like StringIO.new)
can't be dumped itself, but it's blank copy can be dumped
@return [true, false]
# File lib/binding_dumper/dumpers/abstract.rb, line 56 def can_be_dumped_as_copy?(object) begin copy = object.class.allocate Marshal.dump(copy) true rescue TypeError, IOError false end end
can_be_fully_dumped?(object)
click to toggle source
Returns true if abstract_object
can be dumped using Marshal.dump
@return [true, false]
# File lib/binding_dumper/dumpers/abstract.rb, line 42 def can_be_fully_dumped?(object) begin Marshal.dump(object) true rescue TypeError, IOError false end end
should_convert?()
click to toggle source
Returns true
if abstract_object
should be converted
@return [true, false]
# File lib/binding_dumper/dumpers/abstract.rb, line 34 def should_convert? !dumped_ids.include?(abstract_object.object_id) end
undumpable?(object)
click to toggle source
Returns true
if object can’t be marshaled
@return [true, false]
# File lib/binding_dumper/dumpers/abstract.rb, line 70 def undumpable?(object) !can_be_fully_dumped?(object) && !can_be_dumped_as_copy?(object) end