Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ActiveRecord::Base.abstract_class? should return false not nil

#5286

Although this doesn't break anything, but ActiveRecord::Base.abstract_class? returns nil when @abstract_class is not defined. This still works as nil and false are treated as false in conditionals. But Ruby methods ending with a ?, by convention should return true/false. The attached patch ensures that it does return false if @abstract_class is not defined.

IMHO no test was needed as the existing tests cover the functionality provided by the method.

Credit: Neeraj Singh for originally spotting the discrepancy.

Reported by Rohit Arondekar · August 3rd, 2010 @ 03:51 PM

State: invalid
Milestone: 3.0.2
Assigned to: Santiago Pastorino Santiago Pastorino
Importance: Low

Activity

  1. Neeraj Singh
    Neeraj Singh

    I think you should add the test that method returns false and not nil :-)

    August 3rd, 2010 @ 04:16 PM

  2. Rohit Arondekar
  3. Rohit Arondekar
    Rohit Arondekar
    • State changed from new to invalid

    This is actually not needed as both nil and false behave the same. Also it's acceptable that a method ending with a ? return either nil or false if the condition is not satisfied. Closing ticket. :)

    August 4th, 2010 @ 03:29 AM

  4. Jeremy Kemper