1 |
# frozen_string_literal: true
|
|
2 |
|
|
|
require_relative 'value'
|
4✔ |
4 |
|
|
|
module LedgerSync |
4✔ |
|
module Type |
4✔ |
|
class ID < Value # :nodoc: |
4✔ |
|
include ValueMixin
|
4✔ |
9 |
|
|
|
def cast? |
4✔ |
|
true
|
× |
12 |
end
|
|
13 |
|
|
|
def changed_in_place?(raw_old_value, new_value) |
4✔ |
|
raw_old_value != new_value if new_value.is_a?(::String) |
× |
16 |
end
|
|
17 |
|
|
|
def type |
4✔ |
|
:id
|
× |
20 |
end
|
|
21 |
|
|
|
def valid_classes |
4✔ |
|
[::String, ::Symbol, ::Integer, ::NilClass] |
1,344✔ |
24 |
end
|
|
25 |
|
|
|
private |
4✔ |
27 |
|
|
|
def cast_value(args = {}) |
4✔ |
|
value = args.fetch(:value)
|
1,200✔ |
30 |
|
|
|
return if value.nil? |
1,200✔ |
32 |
|
|
|
case value
|
896✔ |
|
when ::String then ::String.new(value) |
672✔ |
|
else value.to_s
|
224✔ |
36 |
end
|
|
37 |
end
|
|
38 |
end
|
|
39 |
end
|
|
40 |
end
|