app/controllers/api_controller/renderer.rb
#
# Let's expand a subcollection
#
Let's expand a subcollection
Let ' s expand a subcollection
def expand_subcollection(json, sc, sctype, subresources)
      if collection_config[sc.to_sym][:options].include?(:show_as_collection)
        copts = {
          :count            => subresources.length,
          :is_subcollection => true,
          :expand_resources => expand?(sc.to_s)
        }
        json.set! sc.to_s, collection_to_jbuilder(sc.to_sym, sctype, subresources, copts)
      else
        json.set! sc.to_s do |js|
          subresources.each do |scr|
            if expand?(sc) || scr["id"].nil?
              add_child js, normalize_hash(sctype, scr, :add_href => true)
            else
              js.child! { |jsc| jsc.href normalize_href(sctype, scr["id"]) }
            end
          end
        end
      end
    end
def expand_subcollection ( json , sc , sctype , subresources ) if collection_config [ sc . to_sym ] [ :options ] . include? ( :show_as_collection ) copts = { :count => subresources . length , :is_subcollection => true , :expand_resources => expand? ( sc . to_s ) } json . set! sc . to_s , collection_to_jbuilder ( sc . to_sym , sctype , subresources , copts ) else json . set! sc . to_s do | js | subresources . each do | scr | if expand? ( sc ) || scr [ "id" ] . nil? add_child js , normalize_hash ( sctype , scr , :add_href => true ) else js . child! { | jsc | jsc . href normalize_href ( sctype , scr [ "id" ] ) } end end end end end
Let's expand a subcollection
Let ' s expand a subcollection
json
<not_specific>
sc
<not_specific>
sctype
<not_specific>
subresources
<not_specific>