Class: CouchPotato::Persistence::TypeCaster

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

Overview

:nodoc:

Constant Summary

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) cast(value, type)



6
7
8
9
10
11
12
13
14
15
# File 'lib/couch_potato/persistence/type_caster.rb', line 6

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) } if value
  else
    cast_native(value, type)
  end
end