Class: Smooth::Query::Response

Inherits:
Response show all
Defined in:
lib/smooth/query.rb

Instance Attribute Summary

Attributes inherited from Response

#command_action, #current_user, #event_namespace, #outcome, #request_headers, #serializer_klass, #serializer_options, #success

Instance Method Summary collapse

Methods inherited from Response

#body, #headers, #initialize, #status, #success?, #to_rack

Constructor Details

This class inherits a constructor from Smooth::Response

Instance Method Details

#objectObject



181
182
183
184
185
186
187
188
189
# File 'lib/smooth/query.rb', line 181

def object
  return @object if @object

  if command_action.to_sym == :find
    outcome.result
  elsif success? && command_action.to_sym == :query
    outcome.result.to_a
  end
end

#optionsObject



174
175
176
177
178
179
# File 'lib/smooth/query.rb', line 174

def options
  @serializer_options.tap do |o|
    o[:each_serializer] = @serializer unless command_action == :find
    o[:scope] = current_user
  end
end

#serializerObject



166
167
168
169
170
171
172
# File 'lib/smooth/query.rb', line 166

def serializer
  if command_action.to_sym == :find
    @serializer
  else
    Smooth::ArraySerializer
  end
end