1 class ApplicationController < ActionController::Base
3 before_filter :uncamelcase_params_hash_keys
4 before_filter :find_object_by_uuid, :except => :index
7 @objects ||= model_class.all
16 @attrs = params[resource_name]
17 if @attrs.class == String
18 @attrs = uncamelcase_hash_keys(JSON.parse @attrs)
20 @object = model_class.new @attrs
28 controller_name.classify.constantize
31 def resource_name # params[] key used by client
32 controller_name.classify.camelcase(:lower)
35 def find_object_by_uuid
36 logger.info params.inspect
37 @object = model_class.where('uuid=?', params[:uuid]).first
40 def uncamelcase_params_hash_keys
41 uncamelcase_hash_keys(params)
44 def uncamelcase_hash_keys(h)
50 elsif k.class == Symbol
51 nk = k.to_s.underscore.to_sym
55 nh[nk] = uncamelcase_hash_keys(v)
64 :kind => "orvos##{resource_name}List",
67 :next_page_token => "",
69 :items => @objects.map { |x| x }
71 render json: @object_list