avdi / naught

A toolkit for building Null Object classes in Ruby
MIT License
1.05k stars 53 forks source link

black_hole and Marshal.dump don't work together? #72

Open nanaya opened 6 years ago

nanaya commented 6 years ago

Is the user supposed to define their own #marshal_dump so it can work with Marshal?

NullObject = Naught.build { |c| c.black_hole }
# fails because marshal_dump returns itself and triggers recursive loop failsafe
Marshal.load(Marshal.dump(NullObject.new))

NullObjectWithDump = Naught.build do |c|
  c.black_hole

  def marshal_dump
  end
end
# works
Marshal.load(Marshal.dump(NullObjectWithDump.new))