Module: Railsful::Interceptors::Sorting
- Included in:
- Serializer
- Defined in:
- lib/railsful/interceptors/sorting.rb
Overview
Interceptor that sorts a given ActiveRecord::Relation
Instance Method Summary collapse
Instance Method Details
#render(options) ⇒ Object
7 8 9 |
# File 'lib/railsful/interceptors/sorting.rb', line 7 def render() super(()) end |
#sorting_options(options) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/railsful/interceptors/sorting.rb', line 11 def () # Check if json value should be sorted. return unless sort?() # Get the relation from options hash so we can sort it relation = .fetch(:json) .merge(json: sort(relation)) end |