Class: Pema::StringType

Inherits:
Field
  • Object
show all
Defined in:
lib/primate/pema.rb

Instance Method Summary collapse

Instance Method Details

#parse(value, coerce = false) ⇒ Object

Raises:



13
14
15
16
17
18
19
20
21
# File 'lib/primate/pema.rb', line 13

def parse(value, coerce = false)
  return value if value.is_a?(String)

  if coerce
    return value.to_s
  end

  raise ValidationError, "expected string, got #{value.class}"
end