Module: Marshal

Defined in:
lib/robot-army/marshal_ext.rb

Class Method Summary collapse

Class Method Details

.can_dump?(object) ⇒ Boolean

Determines whether a given object can be dumped.

Parameters:

  • object

    Object The object to check.

Returns:

  • (Boolean)

    true if dumping the object does not raise an error, false if a TypeError is raised.

Raises:

  • Exception Whatever Marshal.dump might raise that isn’t a TypeError.



15
16
17
18
19
20
21
22
# File 'lib/robot-army/marshal_ext.rb', line 15

def can_dump?(object)
  begin
    Marshal.dump(object)
    return true
  rescue TypeError
    return false
  end
end