Class: Spree::Classifications::Reposition
- Inherits:
-
Object
- Object
- Spree::Classifications::Reposition
- Includes:
- ServiceModule::Base
- Defined in:
- app/services/spree/classifications/reposition.rb
Instance Method Summary collapse
Methods included from ServiceModule::Base
Instance Method Details
#call(classification:, position:) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'app/services/spree/classifications/reposition.rb', line 6 def call(classification:, position:) if position.is_a?(String) && !position.match(/^\d+$/) return failure(nil, I18n.t('errors.messages.not_a_number')) end # Because position we get back is 0-indexed. # acts_as_list is 1-indexed. classification.insert_at(position.to_i + 1) success(classification) end |