Class: FlatKit::FieldType::StringType

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

Overview

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

Methods included from DescendantTracker

#children, #find_child, #find_children, #inherited

Class Method Details

.coerce(data) ⇒ Object



15
16
17
18
19
# File 'lib/flat_kit/field_type/string_type.rb', line 15

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

.matches?(data) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/flat_kit/field_type/string_type.rb', line 11

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

.type_nameObject



7
8
9
# File 'lib/flat_kit/field_type/string_type.rb', line 7

def self.type_name
  "string"
end