lib/lazy_resource/mapping.rb in lazy_resource-0.3.3 vs lib/lazy_resource/mapping.rb in lazy_resource-0.4.0
- old
+ new
@@ -42,18 +42,19 @@
end
end
end
def mapped_root_node_name(objects)
- if self.root_node_name
+ if self.root_node_name && objects.respond_to?(:keys)
root_node_names = self.root_node_name.is_a?(Array) ? self.root_node_name : [self.root_node_name]
mapped_name = (root_node_names.map(&:to_s) & objects.keys).first
end
end
end
def load(hash, persisted=true)
hash.fetched = true and return hash if hash.kind_of?(LazyResource::Mapping)
+ return if hash.nil?
self.tap do |resource|
resource.persisted = persisted
resource.fetched = false