Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

implement AS::Duration#send and #try to avoid unexpected behavior #320

Closed
wants to merge 1 commit into
from
Commits on Apr 27, 2011
  1. implement AS::Duration#send and #try to avoid unexpected behavior

    misfo committed Apr 27, 2011
    since Duration inherits from BasicObject, send and try aren't implemented so
    they're delegated to the Integer value by method_missing.  This causes
    unexpected behavior:
    
      d = 1.day
      d.inspect                #=> "1 day"
      d.try(:inspect) || "N/A" #=> "86400"
      # ^^^ standard null checking goes pear-shaped