lib/cfoundry/v2/model.rb in cfoundry-0.4.7 vs lib/cfoundry/v2/model.rb in cfoundry-0.4.8

- old
+ new

@@ -50,13 +50,16 @@ # this does a bit of extra processing to allow for # `delete!' followed by `create!' def create! payload = {} + @manifest ||= {} + @manifest[:entity] ||= {} + self.class.defaults.merge(@manifest[:entity]).each do |k, v| if v.is_a?(Hash) && v.key?(:metadata) # skip; there's a _guid attribute already - elsif v.is_a?(Array) && v.all? { |x| + elsif v.is_a?(Array) && !v.empty? && v.all? { |x| x.is_a?(Hash) && x.key?(:metadata) } singular = k.to_s.sub(/s$/, "") payload[:"#{singular}_guids"] = v.collect do |x|