app/controllers/api_controller/renderer.rb
#
# Given a resource, return its serialized flavor using Jbuilder
#
Given a resource, return its serialized flavor using Jbuilder
Given a resource return its serialized flavor using Jbuilder
def collection_to_jbuilder(type, reftype, resources, opts = {})
      Jbuilder.new do |json|
        json.ignore_nil!
        [:name, :count, :subcount].each do |opt_name|
          json.set! "#{opt_name}", opts[opt_name] if opts[opt_name]
        end
        json.resources resources.collect do |resource|
          if opts[:expand_resources]
            add_hash json, resource_to_jbuilder(type, reftype, resource, opts).attributes!
          else
            json.href normalize_href(reftype, resource["id"])
          end
        end
        aspecs = get_aspecs(type, opts[:collection_actions], :collection,
                            :is_subcollection => opts[:is_subcollection], :ref => reftype)
        add_actions(json, aspecs, reftype)
      end
    end
def collection_to_jbuilder ( type , reftype , resources , opts = { } ) Jbuilder . new do | json | json . ignore_nil! [ :name , :count , :subcount ] . each do | opt_name | json . set! "#{opt_name}" , opts [ opt_name ] if opts [ opt_name ] end json . resources resources . collect do | resource | if opts [ :expand_resources ] add_hash json , resource_to_jbuilder ( type , reftype , resource , opts ) . attributes! else json . href normalize_href ( reftype , resource [ "id" ] ) end end aspecs = get_aspecs ( type , opts [ :collection_actions ] , :collection , :is_subcollection => opts [ :is_subcollection ] , :ref => reftype ) add_actions ( json , aspecs , reftype ) end end
Given a resource, return its serialized flavor using Jbuilder
Given a resource return its serialized flavor using Jbuilder
type
<not_specific>
reftype
<not_specific>
resources
<not_specific>
opts
<not_specific>