Skip to content

Commit

Permalink
Make ActiveSupport::Duration#method_missing delegate blocks to value [#…
Browse files Browse the repository at this point in the history
…5498 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
krekoten authored and josevalim committed Sep 1, 2010
1 parent dba4efb commit 57693d1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/duration.rb
Expand Up @@ -99,7 +99,7 @@ def sum(sign, time = ::Time.current) #:nodoc:
private

def method_missing(method, *args, &block) #:nodoc:
value.send(method, *args)
value.send(method, *args, &block)
end
end
end
8 changes: 8 additions & 0 deletions activesupport/test/core_ext/duration_test.rb
Expand Up @@ -129,6 +129,14 @@ def test_adding_day_across_dst_boundary
assert_equal Time.local(2009,3,29,0,0,0) + 1.day, Time.local(2009,3,30,0,0,0)
end
end

def test_delegation_with_block_works
counter = 0
assert_nothing_raised do
1.minute.times {counter += 1}
end
assert_equal counter, 60
end

protected
def with_env_tz(new_tz = 'US/Eastern')
Expand Down

0 comments on commit 57693d1

Please sign in to comment.