Module: RSchema::Coercers::Date

Extended by:
Date
Included in:
Date
Defined in:
lib/rschema/coercers/date.rb

Overview

Coerces strings into Date objects using Date.parse

Instance Method Summary collapse

Instance Method Details

#build(_schema) ⇒ Object


10
11
12
# File 'lib/rschema/coercers/date.rb', line 10

def build(_schema)
  self
end

#call(value) ⇒ Object


14
15
16
17
18
19
20
# File 'lib/rschema/coercers/date.rb', line 14

def call(value)
  case value
  when ::Date then Result.success(value)
  when ::String then coerce_string(value)
  else Result.failure
  end
end

#will_affect?(value) ⇒ Boolean

Returns:


22
23
24
# File 'lib/rschema/coercers/date.rb', line 22

def will_affect?(value)
  !value.is_a?(::Date)
end