diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-01-31 00:54:01 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-31 00:54:01 -0500 |
commit | 6d8fdd136b0e922be5bb6cc103ffdb244d73248e (patch) | |
tree | f9a1cb6aa6ed9e11e34f69afd88c284a714b6df0 /activesupport/lib | |
parent | ebededb3726a8143a4372fdf19ad10fe9fe2e233 (diff) | |
parent | 3585155f1b1150a027af26434ab96aedd686ca66 (diff) | |
download | rails-6d8fdd136b0e922be5bb6cc103ffdb244d73248e.tar.gz rails-6d8fdd136b0e922be5bb6cc103ffdb244d73248e.tar.bz2 rails-6d8fdd136b0e922be5bb6cc103ffdb244d73248e.zip |
Merge pull request #27824 from kenta-s/raise-an-error-if-no-block-given
Raise an error if FileUpdateChecker#execute is called with no block
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/evented_file_update_checker.rb | 6 | ||||
-rw-r--r-- | activesupport/lib/active_support/file_update_checker.rb | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/evented_file_update_checker.rb b/activesupport/lib/active_support/evented_file_update_checker.rb index ed4604c2df..080111d799 100644 --- a/activesupport/lib/active_support/evented_file_update_checker.rb +++ b/activesupport/lib/active_support/evented_file_update_checker.rb @@ -74,7 +74,11 @@ module ActiveSupport def execute @updated.make_false - @block.call + if @block.nil? + raise ArgumentError, "no block given: #{self.inspect}, please pass a block when you initialize #{self.class}" + else + @block.call + end end def execute_if_updated diff --git a/activesupport/lib/active_support/file_update_checker.rb b/activesupport/lib/active_support/file_update_checker.rb index 2dbbfadac1..1af18541e3 100644 --- a/activesupport/lib/active_support/file_update_checker.rb +++ b/activesupport/lib/active_support/file_update_checker.rb @@ -74,7 +74,11 @@ module ActiveSupport def execute @last_watched = watched @last_update_at = updated_at(@last_watched) - @block.call + if @block.nil? + raise ArgumentError, "no block given: #{self.inspect}, please pass a block when you initialize #{self.class}" + else + @block.call + end ensure @watched = nil @updated_at = nil |