提交 331d080a 编写于 作者: S Sean Griffin

Revert "Made ActiveRecord consistently use ActiveRecord::Type (not"

This reverts commit 671eb742.

This is not a change we would like moving forward.
上级 52852733
......@@ -19,10 +19,6 @@
*Edho Arief*
* Made ActiveRecord consistently use `ActiveRecord::Type` (not `ActiveModel::Type`)
*Iain Beeston*
* Serialize JSON attribute value `nil` as SQL `NULL`, not JSON `null`
*Trung Duc Tran*
......
......@@ -19,7 +19,7 @@ def query_attribute(attr_name)
if Numeric === value || value !~ /[^0-9]/
!value.to_i.zero?
else
return false if ActiveRecord::Type::Boolean::FALSE_VALUES.include?(value)
return false if ActiveModel::Type::Boolean::FALSE_VALUES.include?(value)
!value.blank?
end
elsif value.respond_to?(:zero?)
......
require "active_model/type"
require "active_record/type/helpers"
require "active_record/type/value"
require "active_record/type/internal/abstract_json"
require "active_record/type/internal/timezone"
......@@ -50,6 +48,7 @@ def current_adapter_name
end
end
Helpers = ActiveModel::Type::Helpers
BigInteger = ActiveModel::Type::BigInteger
Binary = ActiveModel::Type::Binary
Boolean = ActiveModel::Type::Boolean
......@@ -60,6 +59,7 @@ def current_adapter_name
String = ActiveModel::Type::String
Text = ActiveModel::Type::Text
UnsignedInteger = ActiveModel::Type::UnsignedInteger
Value = ActiveModel::Type::Value
register(:big_integer, Type::BigInteger, override: false)
register(:binary, Type::Binary, override: false)
......
module ActiveRecord
module Type
Helpers = ActiveModel::Type::Helpers
end
end
module ActiveRecord
module Type
module Internal # :nodoc:
class AbstractJson < Type::Value # :nodoc:
include Type::Helpers::Mutable
class AbstractJson < ActiveModel::Type::Value # :nodoc:
include ActiveModel::Type::Helpers::Mutable
def type
:json
......
module ActiveRecord
module Type
class Serialized < DelegateClass(Type::Value) # :nodoc:
include Type::Helpers::Mutable
class Serialized < DelegateClass(ActiveModel::Type::Value) # :nodoc:
include ActiveModel::Type::Helpers::Mutable
attr_reader :subtype, :coder
......
module ActiveRecord
module Type
class Value < ActiveModel::Type::Value; end
end
end
......@@ -313,8 +313,8 @@ def coder.load(value)
return if value.nil?
value.gsub(" encoded", "")
end
type = Class.new(ActiveRecord::Type::Value) do
include ActiveRecord::Type::Helpers::Mutable
type = Class.new(ActiveModel::Type::Value) do
include ActiveModel::Type::Helpers::Mutable
def serialize(value)
return if value.nil?
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册