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.

[PATCH] Fix 'warning: method redefined' in attr_accessor_with_default for ruby 1.9.2

#5551

Test and fix are attached.
As side effect should be little faster because avoids future calls to attr_reader every time new value assigned.

Reported by Marjan Krekoten' · September 4th, 2010 @ 11:22 AM

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

Activity

  1. Damien MATHIEU
    Damien MATHIEU

    Isn't there something more globally defined which would just need be to be included instead of defining the capture_stderr method ?

    September 4th, 2010 @ 11:32 AM

  2. Marjan Krekoten'
    Marjan Krekoten'

    Maybe. I tried to search, but didn't find.
    Well, if such code exists and you know about it, please tell me and I'll update test.

    September 4th, 2010 @ 11:35 AM

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

    September 5th, 2010 @ 09:07 PM

  4. Rohit Arondekar
    Rohit Arondekar
    • Importance changed from to Low

    I think you can try using:

      capture(:stderr) { ... }
    

    September 12th, 2010 @ 11:34 AM

  5. Marjan Krekoten'
    Marjan Krekoten'
    • Tag set to activesupport, patch, warnings

    Well, you are right. But there is one problem. It is not available in active_support for now. I've created a ticket for that https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets... . If it will be committed, I'll fix this patch. So I think this patch can be hold until then.

    September 16th, 2010 @ 07:46 PM

  6. Marjan Krekoten'
  7. Marjan Krekoten'
    Marjan Krekoten'

    Oops, previous patch caused another warning:

    test/core_ext/module/attr_accessor_with_default_test.rb:38: warning: ambiguous first argument; put parentheses or even spaces
    

    I've attached updated patch.

    September 18th, 2010 @ 10:02 PM

  8. Marjan Krekoten'
    Marjan Krekoten'
    • Assigned user changed from José Valim to Santiago Pastorino

    September 22nd, 2010 @ 08:40 PM

  9. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open
    • Milestone cleared.

    Marjan, you don't need to provide test when you fix a warning. Also the proper fix is to remove the method #{sym} before calling attr_reader #{sym}

    September 25th, 2010 @ 12:17 AM

  10. Marjan Krekoten'
    Marjan Krekoten'

    Ok, I removed test. But I think attr_accessor is better solution. With attr_accessor we avoid any methods rewriting as soon as new value assigned. So every future value assigning will avoid removing reader, then defining new one.

    I've created pull request with updated fix.
    http://github.com/rails/rails/pull/52

    September 25th, 2010 @ 09:01 AM

  11. Repository
  12. Jeremy Kemper