Class: Portunus::TypeCaster
- Inherits:
-
Object
- Object
- Portunus::TypeCaster
- Defined in:
- lib/portunus/type_caster.rb
Constant Summary collapse
- TYPE_MAP =
{ string: ::Portunus::TypeCasters::String, integer: ::Portunus::TypeCasters::Integer, float: ::Portunus::TypeCasters::Float, date: ::Portunus::TypeCasters::Date, datetime: ::Portunus::TypeCasters::DateTime, boolean: ::Portunus::TypeCasters::Boolean }
Class Method Summary collapse
Instance Method Summary collapse
- #cast ⇒ Object
-
#initialize(value:, type: :string) ⇒ TypeCaster
constructor
A new instance of TypeCaster.
- #uncast ⇒ Object
Constructor Details
#initialize(value:, type: :string) ⇒ TypeCaster
Returns a new instance of TypeCaster.
20 21 22 23 |
# File 'lib/portunus/type_caster.rb', line 20 def initialize(value:, type: :string) @value = value @type = type end |
Class Method Details
.cast(value:, type: nil) ⇒ Object
12 13 14 |
# File 'lib/portunus/type_caster.rb', line 12 def self.cast(value:, type: nil) new(value: value, type: type).cast end |
.uncast(value:, type: nil) ⇒ Object
16 17 18 |
# File 'lib/portunus/type_caster.rb', line 16 def self.uncast(value:, type: nil) new(value: value, type: type).uncast end |