Class: Superstore::Types::StringType

Inherits:
Base
  • Object
show all
Defined in:
lib/superstore/types/string_type.rb

Instance Method Summary collapse

Methods inherited from Base

#type

Instance Method Details

#cast_value(value) ⇒ Object



14
15
16
# File 'lib/superstore/types/string_type.rb', line 14

def cast_value(value)
  value.to_s
end

#serialize(str) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/superstore/types/string_type.rb', line 4

def serialize(str)
  return if str.nil?

  unless str.encoding == Encoding::UTF_8
    (str.frozen? ? str.dup : str).force_encoding('UTF-8')
  else
    str
  end
end