lib/decanter/parser/core.rb in decanter-0.8.1 vs lib/decanter/parser/core.rb in decanter-0.8.2
- old
+ new
@@ -9,11 +9,11 @@
module ClassMethods
# Check if allowed, parse if not
def parse(name, values, options={})
case
- when allowed?(values)
+ when allowed?(values) || empty_values?(values)
{ name => values }
else
_parse(name, values, options)
end
end
@@ -41,9 +41,13 @@
# Check for allowed classes
def allowed?(values)
@allowed && Array.wrap(values).all? do |value|
@allowed.any? { |allowed| value.is_a? allowed }
end
+ end
+
+ def empty_values?(values)
+ return true if Array.wrap(values).all? { |value| value.nil? || value == "" }
end
end
end
end
end