Class: Superstore::Types::StringType
- Inherits:
-
BaseType
- Object
- BaseType
- Superstore::Types::StringType
show all
- Defined in:
- lib/superstore/types/string_type.rb
Instance Attribute Summary
Attributes inherited from BaseType
#model, #options
Instance Method Summary
collapse
Methods inherited from BaseType
#decode, #initialize
Instance Method Details
#encode(str) ⇒ Object
4
5
6
7
8
9
10
11
12
|
# File 'lib/superstore/types/string_type.rb', line 4
def encode(str)
raise ArgumentError.new("#{str.inspect} is not a String") unless str.kind_of?(String)
unless str.encoding == Encoding::UTF_8
(str.frozen? ? str.dup : str).force_encoding('UTF-8')
else
str
end
end
|
#typecast(value) ⇒ Object
14
15
16
|
# File 'lib/superstore/types/string_type.rb', line 14
def typecast(value)
value.to_s
end
|