Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for hashes for the extract! method. #52

Merged
merged 1 commit into from Aug 28, 2012
Merged

Conversation

@aantix
Copy link

aantix commented Aug 17, 2012

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
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.
dhh added a commit that referenced this pull request Aug 28, 2012
Added support for hashes for the extract! method.
@dhh dhh merged commit aa6efc7 into rails:master Aug 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.