Class: Superstore::Types::StringType
- Defined in:
- lib/superstore/types/string_type.rb
Instance Attribute Summary
Attributes inherited from BaseType
Instance Method Summary collapse
Methods inherited from BaseType
#decode, #default, #initialize
Constructor Details
This class inherits a constructor from Superstore::Types::BaseType
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 |