Module: LittleWeasel::Modules::OrderValidatable

Included in:
Orderable
Defined in:
lib/LittleWeasel/modules/order_validatable.rb

Overview

This module provides methods to validate a value that can be used in sorting.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.validate_order(order:) ⇒ Object

Raises:

  • (ArgumentError)


10
11
12
13
# File 'lib/LittleWeasel/modules/order_validatable.rb', line 10

def validate_order(order:)
  raise ArgumentError, "Argument order is not an Integer: #{order.class}" unless order.is_a? Integer
  raise ArgumentError, "Argument order '#{order}' is not a a number from 0-n" if order.negative?
end

Instance Method Details

#validate_order(order:) ⇒ Object (private)



10
11
12
13
# File 'lib/LittleWeasel/modules/order_validatable.rb', line 10

def validate_order(order:)
  raise ArgumentError, "Argument order is not an Integer: #{order.class}" unless order.is_a? Integer
  raise ArgumentError, "Argument order '#{order}' is not a a number from 0-n" if order.negative?
end