class ActionController::Base
Public Instance Methods
render(*args)
click to toggle source
Calls superclass method
# File lib/housing_misc/json_slice_render.rb, line 3 def render *args #this will override all render calls in all services so edit with CAUTION options = args.extract_options! param = (MultiJson.load(params['slice_keys']) rescue false) args << transform_options(param,options) super *args end
Private Instance Methods
transform_options(param,options)
click to toggle source
# File lib/housing_misc/json_slice_render.rb, line 13 def transform_options(param,options) if options[:json] and param if options[:json].is_a?(String) options[:json] = MultiJson.load(options[:json]) rescue options[:json] slice_keys = options[:json].is_a?(Hash) or options[:json].is_a?(Array) end if options[:json].is_a?(Hash) valid_json = options[:json] slice_keys = true elsif options[:json].is_a?(Array) valid_json = {:hits => options[:json]} param = {"hits"=>Array.wrap(param)} extract_hits = true slice_keys = true end if slice_keys temp_options = valid_json.deep_slice(*Array.wrap(param)) options[:json] = temp_options if temp_options.present? if extract_hits options[:json] = options[:json]["hits"] end end end if options[:json].is_a?(Hash) or options[:json].is_a?(Array) #will use MultiJson.dump for ALL api calls to decrease api render time in general options[:json] = MultiJson.dump(options[:json]) end options end