dkubb / adamantium

Create immutable objects
MIT License
373 stars 13 forks source link

Do not allow memoization methods with nonzero arity #10

Closed mbj closed 11 years ago

mbj commented 11 years ago

This makes sure the memoizer is not used to create tricky to track down bugs.

Currently adamantium allows the following:

class Foo
  include Adamantium

  def something(x)
    x * 2
  end
  memoize :something
end

foo = Foo.new
foo.something(1) # => 2
foo.something(2) # => 2, Tricky to track down bug.
mbj commented 11 years ago

@dkubb Any problems with this? I'd like to get it merged.

dkubb commented 11 years ago

@mbj I think you can merge this in if you change to use Numeric#nonzero? like I suggested.

mbj commented 11 years ago

CI failed for external and IMHO temporal reason on one ruby https://travis-ci.org/dkubb/adamantium/builds/4056359 I'll merge anyways. This will trigger a new build that I predict to be green.

dkubb commented 11 years ago

@mbj when a single build fails you can always restart it by clicking on the icon in the upper-right that looks like a little gear.. click on "Restart Job".

mbj commented 11 years ago

Thx. Im not a great GUI user ;). BTW I plan to add a rake task to devtools for this job. (Or a CLI task)