Class: CouchPotato::Persistence::TypeCaster

Inherits:
Object
  • Object
show all
Defined in:
lib/couch_potato/persistence/type_caster.rb

Overview

:nodoc:

Constant Summary collapse

NUMBER_REGEX =
/-?\d*\.?\d*/.freeze

Instance Method Summary collapse

Instance Method Details

#cast(value, type) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/couch_potato/persistence/type_caster.rb', line 9

def cast(value, type)
  if type == :boolean
    cast_boolean(value)
  elsif type.instance_of?(Array)
    nested_type = type.first
    value&.map { |val| cast_native(val, nested_type) }
  else
    cast_native(value, type)
  end
end