Class: Portunus::TypeCasters::Date
- Inherits:
-
Object
- Object
- Portunus::TypeCasters::Date
- Defined in:
- lib/portunus/type_casters/date.rb
Class Method Summary collapse
Instance Method Summary collapse
- #cast ⇒ Object
-
#initialize(value:) ⇒ Date
constructor
A new instance of Date.
- #uncast ⇒ Object
Constructor Details
#initialize(value:) ⇒ Date
Returns a new instance of Date.
12 13 14 |
# File 'lib/portunus/type_casters/date.rb', line 12 def initialize(value:) @value = value end |
Class Method Details
.cast(value:) ⇒ Object
4 5 6 |
# File 'lib/portunus/type_casters/date.rb', line 4 def self.cast(value:) new(value: value).cast end |
.uncast(value:) ⇒ Object
8 9 10 |
# File 'lib/portunus/type_casters/date.rb', line 8 def self.uncast(value:) new(value: value).uncast end |
Instance Method Details
#cast ⇒ Object
16 17 18 |
# File 'lib/portunus/type_casters/date.rb', line 16 def cast value.to_s end |
#uncast ⇒ Object
20 21 22 |
# File 'lib/portunus/type_casters/date.rb', line 20 def uncast ::Date.parse(value) end |