instance method serialize

Ruby on Rails 8.1.2

Since v7.1.6

Available in: v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

serialize(value)

No documentation comment.

Parameters

value req
Source
# File activemodel/lib/active_model/type/integer.rb, line 67
      def serialize(value)
        case value
        when ::Integer
          # noop
        when ::String
          int = value.to_i
          if int.zero? && value != "0"
            return if non_numeric_string?(value)
          end
          value = int
        else
          value = super
        end

        if out_of_range?(value)
          raise ActiveModel::RangeError, "#{value} is out of range for #{self.class} with limit #{_limit} bytes"
        end

        value
      end

Defined in activemodel/lib/active_model/type/integer.rb line 67 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveModel::Type::Integer

Type at least 2 characters to search.

↑↓ navigate · open · esc close