Active Model String Type

Attribute type for strings. It is registered under the :string key.

This class is a specialization of ActiveModel::Type::ImmutableString. It performs coercion in the same way, and can be configured in the same way. However, it accounts for mutable strings, so dirty tracking can properly check if a string has changed.

Methods

Instance Public methods

changed_in_place?(raw_old_value, new_value)

📝 Source code
# File activemodel/lib/active_model/type/string.rb, line 16
      def changed_in_place?(raw_old_value, new_value)
        if new_value.is_a?(::String)
          raw_old_value != new_value
        end
      end
🔎 See on GitHub

to_immutable_string()

📝 Source code
# File activemodel/lib/active_model/type/string.rb, line 22
      def to_immutable_string
        ImmutableString.new(
          true: @true,
          false: @false,
          limit: limit,
          precision: precision,
          scale: scale,
        )
      end
🔎 See on GitHub