Class: Wallaby::Sorting::NextBuilder
- Inherits:
-
Object
- Object
- Wallaby::Sorting::NextBuilder
- Defined in:
- lib/services/wallaby/sorting/next_builder.rb
Overview
Pass field_name to generate sort param for its next sort order (e.g. from empty to ‘asc`, from `asc` to `desc`, from `desc` to empty)
Constant Summary collapse
- ASC =
'asc'.freeze
- DESC =
'desc'.freeze
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
Returns a new instance of NextBuilder.
12 13 14 15 |
# File 'lib/services/wallaby/sorting/next_builder.rb', line 12 def initialize(params, hash = nil) @params = params @hash = hash || HashBuilder.build(params[:sort]) end |
Instance Method Details
#next_params(field_name) ⇒ ActionController::Parameters
Update the ‘sort` parameter.
23 24 25 26 27 |
# File 'lib/services/wallaby/sorting/next_builder.rb', line 23 def next_params(field_name) params = clean_params update params, :sort, complete_sorting_str_with(field_name) params end |