Class: ServiceStack::QueryResponse

Inherits:
Object
  • Object
show all
Includes:
DTO
Defined in:
lib/servicestack/types.rb

Overview

The typed Response of AutoQuery Requests.

Use QueryResponse.of(Booking) for a Response that converts its results into the specified Type, which is what generated AutoQuery DTOs return.

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from DTO

#==, included, #initialize, #inspect, #to_hash, #to_json

Class Attribute Details

.results_typeObject

Returns the value of attribute results_type.



150
151
152
# File 'lib/servicestack/types.rb', line 150

def results_type
  @results_type
end

Instance Attribute Details

#metaObject

Returns the value of attribute meta.



147
148
149
# File 'lib/servicestack/types.rb', line 147

def meta
  @meta
end

#offsetObject

Returns the value of attribute offset.



147
148
149
# File 'lib/servicestack/types.rb', line 147

def offset
  @offset
end

#response_statusObject

Returns the value of attribute response_status.



147
148
149
# File 'lib/servicestack/types.rb', line 147

def response_status
  @response_status
end

#resultsObject

Returns the value of attribute results.



147
148
149
# File 'lib/servicestack/types.rb', line 147

def results
  @results
end

#totalObject

Returns the value of attribute total.



147
148
149
# File 'lib/servicestack/types.rb', line 147

def total
  @total
end

Class Method Details

.of(type) ⇒ Object

A QueryResponse that converts its results into the specified Type.



153
154
155
156
157
158
# File 'lib/servicestack/types.rb', line 153

def of(type)
  @of_types ||= {}
  @of_types[type] ||= Class.new(self) do
    self.results_type = type
  end
end

.propertiesObject



160
161
162
163
164
165
166
167
168
# File 'lib/servicestack/types.rb', line 160

def properties
  {
    offset: { name: 'offset' },
    total: { name: 'total' },
    results: { name: 'results', type: [results_type].compact },
    meta: { name: 'meta' },
    response_status: { name: 'responseStatus', type: ResponseStatus },
  }
end