From af2129b4c74732c88ffce76e5c55c805cb9431f6 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Thu, 1 Aug 2019 16:41:26 +0900 Subject: Use `try` only when we're unsure if the receiver would respond_to the method --- activejob/lib/active_job/core.rb | 4 ++-- activejob/test/support/integration/dummy_app_template.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'activejob') 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 -- cgit v1.2.3