rails/jbuilder — pull request #52 by aantix (2012-08-17 20:25:03+00:00)
Title: Added support for hashes for the extract! method.

extract! can now take a Hash object and associated keys and will generate json output anaologous to an object and it's declared output attributes.

So, instead of using a set! with hash key/values:

questions = [{:text => "Question 1"}, {:text => "Question 2"}]

json.array!(security_questions) do |json, security_question|
json.set!(:text, security_question[:text])
end

It can now be achieved with the same syntax as a normal object:

json.array!(security_questions) do |json, security_question|
json.(security_question, :text)
end