class ActiveModel::Type::Binary

Non-string values are coerced to strings using their to_s method.
under the :binary key.
Attribute type for representation of binary data. This type is registered
= Active Model Binary Type

def binary?

def binary?
  true
end

def cast(value)

def cast(value)
  if value.is_a?(Data)
    value.to_s
  else
    value = super
    value = value.b if ::String === value && value.encoding != Encoding::BINARY
    value
  end
end

def changed_in_place?(raw_old_value, value)

def changed_in_place?(raw_old_value, value)
  old_value = deserialize(raw_old_value)
  old_value != value
end

def serialize(value)

def serialize(value)
  return if value.nil?
  Data.new(super)
end

def type

def type
  :binary
end