3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/hash_cast/casters/array_caster.rb', line 3
def self.cast(value, attr_name, options = {})
unless value.is_a?(Array)
raise HashCast::Errors::CastingError, "should be an array"
end
if HashCast.config.array_size_validator_enabled
if value.size > HashCast.config.array_size_validator_limit
HashCast.config.array_size_validator_callback.call(value, attr_name, options)
end
end
if options[:each]
cast_array_items(value, attr_name, options)
else
value
end
end
|