aboutsummaryrefslogblamecommitdiffstats
path: root/activemodel/lib/active_model/type/string.rb
blob: 0d9f4a63b446fd7e7b9974632e1eb3996ea2fc00 (plain) (tree)
1
2
3
4
5
6
7

                             
                                            
 
                  
             
                                            





                                                     
             
                             

                                                

                             

                         
           


       
# frozen_string_literal: true

require "active_model/type/immutable_string"

module ActiveModel
  module Type
    class String < ImmutableString # :nodoc:
      def changed_in_place?(raw_old_value, new_value)
        if new_value.is_a?(::String)
          raw_old_value != new_value
        end
      end

      private
        def cast_value(value)
          case value
          when ::String then ::String.new(value)
          when true then "t"
          when false then "f"
          else value.to_s
          end
        end
    end
  end
end