Module: RSchema::Coercers::Time

Extended by:
Time
Included in:
Time
Defined in:
lib/rschema/coercers/time.rb

Overview

Coerces ‘String`s to `Time`s using `Time.parse`

Instance Method Summary collapse

Instance Method Details

#build(_schema) ⇒ Object



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

def build(_schema)
  self
end

#call(value) ⇒ Object



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

def call(value)
  case value
  when ::Time 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/time.rb', line 22

def will_affect?(value)
  !value.is_a?(Time)
end