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.

ActiveSupport::Duration is not properly delegating to its value

#5498

http://github.com/rails/rails/blob/master/activesupport/lib/active_...

Line 102 should probably be value.send(method, *args, &block)... In the current code anything which requires a block won't work properly. For instance, 1.day.times { puts 'Hello' } returns an Enumerator instead of doing what you expected. Now maybe it doesn't make sense to call times on a duration, but point being anything that requires a block won't work.

If this is for some odd reason the right behaviour it really should be documented in the code.

I'm in a hurry now so if someone could attach the tests and patches for this it'd be great. Otherwise I'll do it tonight.

Reported by Godfrey Chan · August 30th, 2010 @ 03:09 PM

State: resolved
Milestone: none
Assigned to: José Valim José Valim
Importance: none

Activity

  1. Marjan Krekoten'
    Marjan Krekoten'
    • Tag changed from delegate method, activesupport, duration, method_missing to delegate method, activesupport, duration, method_missing, patch

    I've attached patch with fix suggested by Godfrey Chan and test for it.

    August 30th, 2010 @ 08:57 PM

  2. Godfrey Chan
  3. Godfrey Chan
    Godfrey Chan

    Test on my system (rvm 1.8.7 + 1.9.2), the test passed and the patch worked flawlessly.

    August 31st, 2010 @ 04:36 PM

  4. Marjan Krekoten'
    Marjan Krekoten'
    • Assigned user set to José Valim

    September 1st, 2010 @ 07:00 AM

  5. Repository
    Repository
    • State changed from new to resolved

    (from [2adad2a0cc6e6179cb03b6e2c61d7e8efd46389e]) Make ActiveSupport::Duration#method_missing delegate blocks to value [#5498 state:resolved]

    Signed-off-by: José Valim jose.valim@gmail.com
    http://github.com/rails/rails/commit/2adad2a0cc6e6179cb03b6e2c61d7e...

    September 1st, 2010 @ 09:15 AM

  6. Repository
    Repository

    (from [57693d1362dcde9e0e32689255a22414488e1335]) Make ActiveSupport::Duration#method_missing delegate blocks to value [#5498 state:resolved]

    Signed-off-by: José Valim jose.valim@gmail.com
    http://github.com/rails/rails/commit/57693d1362dcde9e0e32689255a224...

    September 1st, 2010 @ 09:15 AM