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.
21 22 23 24 25 26 |
# File 'lib/might/sort_parameter.rb', line 21 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)
16 17 18 |
# File 'lib/might/sort_parameter.rb', line 16 def definition @definition end |
#direction ⇒ 'asc', desc' (readonly)
45 46 47 |
# File 'lib/might/sort_parameter.rb', line 45 def direction @direction end |
#validator ⇒ Object (readonly)
Returns the value of attribute validator.
28 29 30 |
# File 'lib/might/sort_parameter.rb', line 28 def validator @validator end |
Instance Method Details
#==(other) ⇒ Object
37 38 39 40 41 |
# File 'lib/might/sort_parameter.rb', line 37 def ==(other) is_a?(other.class) && direction == other.direction && definition == other.definition end |
#errors ⇒ Object
33 34 35 |
# File 'lib/might/sort_parameter.rb', line 33 def errors validator.errors. end |