Skip to content

Commit

Permalink
I find this constant name better
Browse files Browse the repository at this point in the history
  • Loading branch information
fidel committed Nov 4, 2023
1 parent 3d4a916 commit ed055df
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module ActiveRecord
InvalidDataTypeForAdapter = Class.new(StandardError)

class DatabaseAdapter
NOT_SET = Object.new.freeze
NONE = Object.new.freeze

class PostgreSQL < self
SUPPORTED_DATA_TYPES = %w[binary json jsonb].freeze
Expand Down Expand Up @@ -40,7 +40,7 @@ def adapter_name
end
end

def initialize(data_type = NOT_SET)
def initialize(data_type = NONE)
raise UnsupportedAdapter if instance_of?(DatabaseAdapter)

validate_data_type!(data_type)
Expand All @@ -67,7 +67,7 @@ def hash
def template_directory
end

def self.from_string(adapter_name, data_type = NOT_SET)
def self.from_string(adapter_name, data_type = NONE)
raise NoMethodError unless eql?(DatabaseAdapter)

case adapter_name.to_s.downcase
Expand All @@ -85,7 +85,7 @@ def self.from_string(adapter_name, data_type = NOT_SET)
private

def validate_data_type!(data_type)
if !data_type.eql?(NOT_SET) && !supported_data_types.include?(data_type)
if !data_type.eql?(NONE) && !supported_data_types.include?(data_type)
raise InvalidDataTypeForAdapter,
"#{class_name} doesn't support #{data_type.inspect}. Supported types are: #{supported_data_types.join(", ")}."
end
Expand Down

0 comments on commit ed055df

Please sign in to comment.