blob: 6ba2c2a3d2c7e4d0f241211c32a9e923d2afde4b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# frozen_string_literal: true
require_relative "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
|