Sha256: c77830deeddc2ab22f2b8f043b0fba57924a838d0d7199649420f811390c12d3

Contents?: true

Size: 607 Bytes

Versions: 53

Compression:

Stored size: 607 Bytes

Contents

# frozen_string_literal: true

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

53 entries across 53 versions & 8 rubygems

Version Path
activemodel-6.0.2.rc2 lib/active_model/type/immutable_string.rb
activemodel-5.2.4 lib/active_model/type/immutable_string.rb
activemodel-6.0.2.rc1 lib/active_model/type/immutable_string.rb
activemodel-5.2.4.rc1 lib/active_model/type/immutable_string.rb
activemodel-6.0.1 lib/active_model/type/immutable_string.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/activemodel-6.0.0/lib/active_model/type/immutable_string.rb
activemodel-6.0.1.rc1 lib/active_model/type/immutable_string.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/activemodel-6.0.0/lib/active_model/type/immutable_string.rb
activemodel-6.0.0 lib/active_model/type/immutable_string.rb
spiral_form-0.1.1 vendor/bundle/gems/activemodel-5.2.3/lib/active_model/type/immutable_string.rb
spiral_form-0.1.0 vendor/bundle/gems/activemodel-5.2.3/lib/active_model/type/immutable_string.rb
activemodel-6.0.0.rc2 lib/active_model/type/immutable_string.rb
ric-0.13.0 vendor/bundle/ruby/2.5.0/gems/activemodel-5.2.3/lib/active_model/type/immutable_string.rb
ric-0.12.2 vendor/bundle/ruby/2.5.0/gems/activemodel-5.2.3/lib/active_model/type/immutable_string.rb
activemodel-6.0.0.rc1 lib/active_model/type/immutable_string.rb
activemodel-5.2.3 lib/active_model/type/immutable_string.rb
activemodel-5.2.3.rc1 lib/active_model/type/immutable_string.rb
activemodel-6.0.0.beta3 lib/active_model/type/immutable_string.rb
activemodel-5.2.2.1 lib/active_model/type/immutable_string.rb
activemodel-6.0.0.beta2 lib/active_model/type/immutable_string.rb