lib/alba/many.rb in alba-0.13.0 vs lib/alba/many.rb in alba-0.13.1
- old
+ new
@@ -9,9 +9,11 @@
# @param params [Hash] user-given Hash for arbitrary data
# @return [Array<Hash>]
def to_hash(target, params: {})
objects = target.public_send(@name)
objects = @condition.call(objects, params) if @condition
+ return if objects.nil?
+
objects.map { |o| @resource.new(o, params: params).to_hash }
end
end
end