aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/file_update_checker.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2017-01-31 01:15:07 -0500
committerRafael Mendonça França <rafaelmfranca@gmail.com>2017-01-31 01:15:07 -0500
commit44901ca9039dcf512a706b06c77e11004e661666 (patch)
tree39b40ecac2bd4c9d176252e3f7ff7dba3453afbb /activesupport/lib/active_support/file_update_checker.rb
parent6d8fdd136b0e922be5bb6cc103ffdb244d73248e (diff)
downloadrails-44901ca9039dcf512a706b06c77e11004e661666.tar.gz
rails-44901ca9039dcf512a706b06c77e11004e661666.tar.bz2
rails-44901ca9039dcf512a706b06c77e11004e661666.zip
Raise in the initialize not in the execute
Diffstat (limited to 'activesupport/lib/active_support/file_update_checker.rb')
-rw-r--r--activesupport/lib/active_support/file_update_checker.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/file_update_checker.rb b/activesupport/lib/active_support/file_update_checker.rb
index 1af18541e3..2b5e3c1350 100644
--- a/activesupport/lib/active_support/file_update_checker.rb
+++ b/activesupport/lib/active_support/file_update_checker.rb
@@ -38,6 +38,10 @@ module ActiveSupport
# changes. The array of files and list of directories cannot be changed
# after FileUpdateChecker has been initialized.
def initialize(files, dirs = {}, &block)
+ unless block
+ raise ArgumentError, "A block is required to initialize a FileUpdateChecker"
+ end
+
@files = files.freeze
@glob = compile_glob(dirs)
@block = block
@@ -74,11 +78,7 @@ module ActiveSupport
def execute
@last_watched = watched
@last_update_at = updated_at(@last_watched)
- if @block.nil?
- raise ArgumentError, "no block given: #{self.inspect}, please pass a block when you initialize #{self.class}"
- else
- @block.call
- end
+ @block.call
ensure
@watched = nil
@updated_at = nil