class Object

Public Instance Methods

json(hash = {}) click to toggle source
Calls superclass method
# File lib/picatrix/templates/app.rb, line 29
  def json(hash = {})
    # anything set here will be sent in all responses
    super(<%= @namespaces %>.merge!(hash))
  end

<% @routes.unique_routes.each do |route| %>
<%= route[:method] %> "/<%= route[:path] %>" do
<% if route[:response_resource][:collection] %>
     response_body = {"<%= route[:response_resource][:name].to_s.underscore %>" => <%= route[:response_resource][:name] %>Resource.as_hashes}
<% else %>
     response_body = <%= route[:response_resource][:name].to_s.pluralize.constantize %>Resource.<%= send_method_for(route[:method]).to_s %>(params[:item_id]).to_hash.except(:controls)
<% end %>
     controls = {}
<% if @routes.controls[route[:target]][route[:method]] %>
<% @routes.controls[route[:target]][route[:method]].each do |control| %>
     controls.merge!(send("<%= control %>".to_sym, <%= route[:response_resource][:name] %>).call("<%= route[:target] %>".pluralize, params))
<% end %>
<% end %>
     json({
       :@controls => controls
     }.merge!(response_body))
   end
<% end %>