Module: Praxis::Plugins::MapperPlugin::Controller
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/praxis/plugins/mapper_plugin.rb
Instance Method Summary collapse
Instance Method Details
#build_query(base_query) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/praxis/plugins/mapper_plugin.rb', line 50 def build_query(base_query) domain_model = media_type&.domain_model raise "No domain model defined for #{name}. Cannot use the attribute filtering helpers without it" unless domain_model filters = request.params.filters if request.params.respond_to?(:filters) # Handle filters base_query = domain_model.craft_filter_query(base_query, filters: filters) selectors = selector_generator.selectors base_query = domain_model.craft_field_selection_query(base_query, selectors: selectors) # handle pagination and ordering if the pagination extention is included base_query = domain_model.craft_pagination_query(base_query, pagination: _pagination, selectors: selectors) if respond_to?(:_pagination) base_query end |
#selector_generator ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/praxis/plugins/mapper_plugin.rb', line 66 def selector_generator return unless media_type.respond_to?(:domain_model) && media_type.domain_model < Praxis::Mapper::Resource @selector_generator ||= \ Praxis::Mapper::SelectorGenerator.new.add(media_type.domain_model, ) end |