27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/attrio/attributes_parser.rb', line 27
def self.cast_type(constant)
return constant if constant.is_a?(Class) && !!(constant < Attrio::Types::Base)
string = constant.to_s
string = string.camelize if (string =~ /\w_\w/ || string.chars.first.downcase == string.chars.first)
begin
if Attrio::Types.const_defined?(string)
return Attrio::Types.const_get(string)
elsif Object.const_defined?(string)
return Object.const_get(string)
else
return nil
end
rescue
return constant
end
end
|