diff options
author | Akira Matsuda <ronnie@dio.jp> | 2019-08-01 16:41:26 +0900 |
---|---|---|
committer | Akira Matsuda <ronnie@dio.jp> | 2019-08-01 17:58:00 +0900 |
commit | af2129b4c74732c88ffce76e5c55c805cb9431f6 (patch) | |
tree | c74d8c85f81ea6b3a5e4209be247c9d83666bd4d /activejob | |
parent | dbf3e4882f9da95e34ed9086f182cf424aaac224 (diff) | |
download | rails-af2129b4c74732c88ffce76e5c55c805cb9431f6.tar.gz rails-af2129b4c74732c88ffce76e5c55c805cb9431f6.tar.bz2 rails-af2129b4c74732c88ffce76e5c55c805cb9431f6.zip |
Use `try` only when we're unsure if the receiver would respond_to the method
Diffstat (limited to 'activejob')
-rw-r--r-- | activejob/lib/active_job/core.rb | 4 | ||||
-rw-r--r-- | activejob/test/support/integration/dummy_app_template.rb | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/activejob/lib/active_job/core.rb b/activejob/lib/active_job/core.rb index 283125698d..5b10858d80 100644 --- a/activejob/lib/active_job/core.rb +++ b/activejob/lib/active_job/core.rb @@ -100,7 +100,7 @@ module ActiveJob "executions" => executions, "exception_executions" => exception_executions, "locale" => I18n.locale.to_s, - "timezone" => Time.zone.try(:name), + "timezone" => Time.zone&.name, "enqueued_at" => Time.now.utc.iso8601 } end @@ -140,7 +140,7 @@ module ActiveJob self.executions = job_data["executions"] self.exception_executions = job_data["exception_executions"] self.locale = job_data["locale"] || I18n.locale.to_s - self.timezone = job_data["timezone"] || Time.zone.try(:name) + self.timezone = job_data["timezone"] || Time.zone&.name self.enqueued_at = job_data["enqueued_at"] end diff --git a/activejob/test/support/integration/dummy_app_template.rb b/activejob/test/support/integration/dummy_app_template.rb index b56dd3e591..65229ba397 100644 --- a/activejob/test/support/integration/dummy_app_template.rb +++ b/activejob/test/support/integration/dummy_app_template.rb @@ -21,7 +21,7 @@ class TestJob < ActiveJob::Base File.open(Rails.root.join("tmp/\#{x}.new"), "wb+") do |f| f.write Marshal.dump({ "locale" => I18n.locale.to_s || "en", - "timezone" => Time.zone.try(:name) || "UTC", + "timezone" => Time.zone&.name || "UTC", "executed_at" => Time.now.to_r }) end |