From 77c24766362c02769d81dac000b1879a9e4d4a00 Mon Sep 17 00:00:00 2001 From: Pavel Pravosud Date: Wed, 24 Apr 2013 19:58:25 +0700 Subject: [PATCH] Block has priority over attributes extraction --- lib/jbuilder.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/jbuilder.rb b/lib/jbuilder.rb index ffece0e..1500b54 100644 --- a/lib/jbuilder.rb +++ b/lib/jbuilder.rb @@ -225,10 +225,10 @@ def child! # # [1,2,3] def array!(collection, *attributes, &block) - @attributes = if attributes.present? - _map_collection(collection) { |element| extract!(element, *attributes) } - elsif ::Kernel::block_given? + @attributes = if ::Kernel::block_given? _map_collection(collection) { |element| block.arity == 2 ? block[self, element] : block[element] } + elsif attributes.any? + _map_collection(collection) { |element| extract! element, *attributes } else collection end