Class: Wallaby::Sorting::NextBuilder
- Inherits:
-
Object
- Object
- Wallaby::Sorting::NextBuilder
- Defined in:
- lib/services/wallaby/sorting/next_builder.rb
Overview
Generate sort param for given field’s next sort order (e.g. from empty to ‘asc`, from `asc` to `desc`, from `desc` to empty)
Direct Known Subclasses
Constant Summary collapse
- ASC =
'asc'- DESC =
'desc'
Instance Method Summary collapse
-
#initialize(params, hash = nil) ⇒ NextBuilder
constructor
A new instance of NextBuilder.
-
#next_params(field_name) ⇒ ActionController::Parameters
Update the ‘sort` parameter.
Constructor Details
#initialize(params, hash = nil) ⇒ NextBuilder
13 14 15 16 |
# File 'lib/services/wallaby/sorting/next_builder.rb', line 13 def initialize(params, hash = nil) @params = params @hash = hash.try(:with_indifferent_access) || HashBuilder.build(params[:sort]) end |
Instance Method Details
#next_params(field_name) ⇒ ActionController::Parameters
Update the ‘sort` parameter.
24 25 26 27 28 |
# File 'lib/services/wallaby/sorting/next_builder.rb', line 24 def next_params(field_name) params = Utils.clone @params params[:sort] = complete_sorting_str_with field_name params end |