Class: FlatKit::FieldType::StringType

Inherits:
FlatKit::FieldType show all
Defined in:
lib/flat_kit/field_type/string_type.rb

Overview

Internal: StringType is essentially a fallback - hence its lower weight than other types that might have string representations.

Constant Summary

Constants inherited from FlatKit::FieldType

CoerceFailure

Class Method Summary collapse

Methods inherited from FlatKit::FieldType

best_guess, candidate_types, weight, weights

Methods included from DescendantTracker

#children, #find_child, #find_children, #inherited

Class Method Details

.coerce(data) ⇒ Object



17
18
19
20
21
# File 'lib/flat_kit/field_type/string_type.rb', line 17

def self.coerce(data)
  data.to_s
rescue StandardError => _e
  CoerceFailure
end

.matches?(data) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/flat_kit/field_type/string_type.rb', line 13

def self.matches?(data)
  data.is_a?(String)
end

.type_nameObject



9
10
11
# File 'lib/flat_kit/field_type/string_type.rb', line 9

def self.type_name
  "string"
end