From 4603649a89aca569331d65326e6b255952adc6d9 Mon Sep 17 00:00:00 2001 From: alpaca-tc Date: Sun, 11 Jun 2023 22:13:58 +0900 Subject: [PATCH] Remove unused conditions --- lib/active_record_encryption/type.rb | 11 +---------- spec/support/activerecord_model.rb | 6 +----- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/lib/active_record_encryption/type.rb b/lib/active_record_encryption/type.rb index 74d0bdb..7d2633c 100644 --- a/lib/active_record_encryption/type.rb +++ b/lib/active_record_encryption/type.rb @@ -6,7 +6,7 @@ class Type < ActiveRecord::Type::Value delegate :user_input_in_time_zone, to: :subtype # for ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter def initialize( - subtype: default_value, + subtype: ActiveRecord::Type.default_value, encryption: ActiveRecordEncryption.default_encryption.clone, **options ) @@ -37,15 +37,6 @@ def changed_in_place?(raw_old_value, value) attr_reader :subtype, :binary, :encryptor - # NOTE: `ActiveRecord::Type.default_value` is not defined in Rails 5.0 - def default_value - if ActiveRecord.gem_version < Gem::Version.create('5.1.0') - ActiveRecord::Type::Value.new - else - ActiveRecord::Type.default_value - end - end - def build_encryptor(options) encryptor = options.delete(:encryptor) diff --git a/spec/support/activerecord_model.rb b/spec/support/activerecord_model.rb index 3d24d8f..c5363cc 100644 --- a/spec/support/activerecord_model.rb +++ b/spec/support/activerecord_model.rb @@ -113,11 +113,7 @@ alias_attribute :title, :name - if ActiveRecord.gem_version >= Gem::Version.create('5.2.0') - attribute :cancel_save_from_callback - else - attr_accessor :cancel_save_from_callback - end + attribute :cancel_save_from_callback end table do |t|