Sha256: 2fc5002d38863050387d2dbee13c49b01afce46a263e7ec85f8204c92990eb59

Contents?: true

Size: 576 Bytes

Versions: 22

Compression:

Stored size: 576 Bytes

Contents

module ActiveModel
  module Type
    class ImmutableString < Value # :nodoc:
      def type
        :string
      end

      def serialize(value)
        case value
        when ::Numeric, ActiveSupport::Duration then value.to_s
        when true then "t"
        when false then "f"
        else super
        end
      end

      private

        def cast_value(value)
          result = \
            case value
            when true then "t"
            when false then "f"
            else value.to_s
            end
          result.freeze
        end
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
activemodel-5.1.7 lib/active_model/type/immutable_string.rb
activemodel-5.1.7.rc1 lib/active_model/type/immutable_string.rb
activemodel-5.1.6.2 lib/active_model/type/immutable_string.rb
activemodel-5.1.6.1 lib/active_model/type/immutable_string.rb
activemodel-5.1.6 lib/active_model/type/immutable_string.rb
tdiary-5.0.8 vendor/bundle/gems/activemodel-5.1.5/lib/active_model/type/immutable_string.rb
activemodel-5.1.5 lib/active_model/type/immutable_string.rb
activemodel-5.1.5.rc1 lib/active_model/type/immutable_string.rb
activemodel-5.1.4 lib/active_model/type/immutable_string.rb
activemodel-5.1.4.rc1 lib/active_model/type/immutable_string.rb
activemodel-5.1.3 lib/active_model/type/immutable_string.rb
activemodel-5.1.3.rc3 lib/active_model/type/immutable_string.rb
activemodel-5.1.3.rc2 lib/active_model/type/immutable_string.rb
activemodel-5.1.3.rc1 lib/active_model/type/immutable_string.rb
tdiary-5.0.5 vendor/bundle/gems/activemodel-5.1.2/lib/active_model/type/immutable_string.rb
activemodel-5.1.2 lib/active_model/type/immutable_string.rb
activemodel-5.1.2.rc1 lib/active_model/type/immutable_string.rb
activemodel-5.1.1 lib/active_model/type/immutable_string.rb
activemodel-5.1.0 lib/active_model/type/immutable_string.rb
activemodel-5.1.0.rc2 lib/active_model/type/immutable_string.rb