Sha256: 8f5e8d82de320cebff7b373bde2f85e8dd379b386241bef2e8cafa7083690d0d

Contents?: true

Size: 548 Bytes

Versions: 4

Compression:

Stored size: 548 Bytes

Contents

# 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".freeze
        when false then "f".freeze
        else value.to_s
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
options_model-0.0.10 lib/active_model/type/string.rb
options_model-0.0.9 lib/active_model/type/string.rb
options_model-0.0.8 lib/active_model/type/string.rb
options_model-0.0.7 lib/active_model/type/string.rb