codegram / futuroscope

Yet another Futures implementation in Ruby
MIT License
210 stars 13 forks source link

__setobj__ and marshal_load fix #13

Closed ggPeti closed 10 years ago

ggPeti commented 10 years ago

__getobj__ was retrieving :value from @resolved_future, but on the other hand, __setobj__ was not creating a hash with the given value for the :value key. This led to a failure with dup because initialize_dup in Delegator uses these methods to duplicate a delegator.

After a bit of thinking I realized that this was set up intentionally, because marshal_load of Delegator also uses __setobj__, so when we load a dumped object, the correct value from the overridden marshal_dump gets written. But this is a conceptual error, because __getobj__ is supposed to do the opposite of __setobj__, as is marshal_dump supposed to do the opposite of marshal_load. So I overrode the latter, and corrected __setobj__.

josepjaume commented 10 years ago

Awesome! Thank you very much for finding the issue and taking the time to fix it.

josepjaume commented 10 years ago

If I might ask; are you using futuroscope in some project, just playing with it...?

ggPeti commented 10 years ago

Sure, no problem - I'm a developer at WhitePages and I'm looking into using futuroscope in one of the company's products. But it was just by sheer chance that I haven't found it first for a personal project. I love its interface, especially the convenience methods, it feels very ruby-ish :) :+1: