Class: Might::SortParameter
- Inherits:
-
Object
- Object
- Might::SortParameter
- Defined in:
- lib/might/sort_parameter.rb
Overview
User provided filtering on particular parameter
Constant Summary collapse
- DIRECTIONS =
%w(asc desc).freeze
- REVERSED_DIRECTIONS =
{ 'asc' => 'desc', 'desc' => 'asc', }.freeze
Instance Attribute Summary collapse
- #definition ⇒ ParameterDefinition readonly
- #direction ⇒ 'asc', desc' readonly
-
#validator ⇒ Object
readonly
Returns the value of attribute validator.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #errors ⇒ Object
-
#initialize(direction, definition) ⇒ SortParameter
constructor
A new instance of SortParameter.
Constructor Details
#initialize(direction, definition) ⇒ SortParameter
Returns a new instance of SortParameter.
22 23 24 25 26 27 |
# File 'lib/might/sort_parameter.rb', line 22 def initialize(direction, definition) @direction = direction.to_s fail ArgumentError unless DIRECTIONS.include?(@direction) @definition = definition @validator = definition.validator end |
Instance Attribute Details
#definition ⇒ ParameterDefinition (readonly)
17 18 19 |
# File 'lib/might/sort_parameter.rb', line 17 def definition @definition end |
#direction ⇒ 'asc', desc' (readonly)
46 47 48 |
# File 'lib/might/sort_parameter.rb', line 46 def direction @direction end |
#validator ⇒ Object (readonly)
Returns the value of attribute validator.
29 30 31 |
# File 'lib/might/sort_parameter.rb', line 29 def validator @validator end |
Instance Method Details
#==(other) ⇒ Object
38 39 40 41 42 |
# File 'lib/might/sort_parameter.rb', line 38 def ==(other) is_a?(other.class) && direction == other.direction && definition == other.definition end |
#errors ⇒ Object
34 35 36 |
# File 'lib/might/sort_parameter.rb', line 34 def errors validator.errors. end |