@where = params[:where]
elsif params[:where].is_a? String
begin
- @where = Oj.load(params[:where])
+ @where = Oj.load(params[:where], symbol_keys: true)
rescue
raise ArgumentError.new("Could not parse \"where\" param as an object")
end
if !@where.empty?
conditions = ['1=1']
@where.each do |attr,value|
- if attr == 'any' or attr == :any
+ if attr == :any
if value.is_a?(Array) and
value[0] == 'contains' and
model_class.columns.collect(&:name).index('name') then
return @attrs if @attrs
@attrs = params[resource_name]
if @attrs.is_a? String
- @attrs = Oj.load @attrs
+ @attrs = Oj.load @attrs, symbol_keys: true
end
unless @attrs.is_a? Hash
message = "No #{resource_name}"
if params[:id] and params[:id].match /\D/
params[:uuid] = params.delete :id
end
- @object = model_class.where('uuid=?', params[:uuid]).first
+ @where = { uuid: params[:uuid] }
+ find_objects_for_index
+ @object = @objects.first
end
def self.accept_attribute_as_json(attr, force_class=nil)
def accept_attribute_as_json(attr, force_class)
if params[resource_name].is_a? Hash
if params[resource_name][attr].is_a? String
- params[resource_name][attr] = Oj.load params[resource_name][attr]
+ params[resource_name][attr] = Oj.load(params[resource_name][attr],
+ symbol_keys: true)
if force_class and !params[resource_name][attr].is_a? force_class
raise TypeError.new("#{resource_name}[#{attr.to_s}] must be a #{force_class.to_s}")
end
def render *opts
response = opts.first[:json]
- if response &&
+ if response.is_a?(Hash) &&
params[:_profile] &&
- response.respond_to?(:[]) &&
Thread.current[:request_starttime]
response[:_profile] = {
request_time: Time.now - Thread.current[:request_starttime]