Toxic Elephant

Redefined Accessors

Posted by matijs 10/12/2010 at 09h29

If you’re going to do this:

  def foo= f
    @foo = f + " bar"
  end

Then don’t first do this:

  attr_accessor :foo

But instead do this:

  attr_reader :foo

That way, there won’t be “method redefined” warnings all over the place.

Let’s make this more general: Before you release your gem, make sure it runs without warnings. They should stick out like a sore thumb when you run your tests, anyway.

Thanks.

Posted in  | no comments | no trackbacks

No comments

No trackbacks

Comments are disabled

Toxic Elephant is Matijs van Zuijlen's weblog.

Powered

Categories

Archives