aparod/jsonify — comment on commit 797d8b2bfa13b954ee1ae9fc03ff15789e312811
File:  line 0
By bsiggelkow:

Hmm -- I don't think this would be good ... for one, it would break compatibility ... instead of using the value given, it will potentially call a method on that value unintended. Suppose I have a Witch object;

class Witch
def hex
'eye of newt'
end
end

json.witches(@witches) do |witch|
json.hex witch.hex
end

Instead of using the value 'eye of newt'; it will use the value 14 (because the string 'eye of newt' responds to 'hex' and returns 14).

Thinking out loud here: an alternative to potentially dry things up could be something like this (using your example):

json.users(@users) do |u|
json.attrs! u, :id, :username, :first_name, :last_name
end