Module: AppQuery::Mappable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/app_query/mappable.rb
Overview
Note:
Middleware concern that maps query results to Ruby objects in BaseQuery subclasses.
Include this module to automatically convert result hashes into typed objects like +Data+ classes or +Struct+s.
By default, looks for an +Item+ constant in the query class. Use +map_to+ to specify a different class.
Instance Method Summary collapse
-
#query ⇒ Object
Append our transform to the underlying Q's RowBuilder pipeline so every row-returning path (entries, first, last, take, with_select(...).first, …) sees mapped rows.
- #raw ⇒ Object
Instance Method Details
#query ⇒ Object
Append our transform to the underlying Q's RowBuilder pipeline so every
row-returning path (entries, first, last, take, with_select(...).first,
…) sees mapped rows. Stacks with other row-level middlewares in
include-order — earlier includes run first.
73 74 75 |
# File 'lib/app_query/mappable.rb', line 73 def query @query ||= super.tap { |q| q.row_builder << method(:build_row) } end |
#raw ⇒ Object
64 65 66 67 |
# File 'lib/app_query/mappable.rb', line 64 def raw @raw = true self end |