Class: YADM::Criteria::Order::Clause
- Inherits:
-
Object
- Object
- YADM::Criteria::Order::Clause
- Defined in:
- lib/yadm/criteria/order.rb
Instance Attribute Summary collapse
-
#expression ⇒ Object
readonly
Returns the value of attribute expression.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #asc? ⇒ Boolean
- #desc? ⇒ Boolean
-
#initialize(type, expression) ⇒ Clause
constructor
A new instance of Clause.
Constructor Details
#initialize(type, expression) ⇒ Clause
Returns a new instance of Clause.
27 28 29 30 |
# File 'lib/yadm/criteria/order.rb', line 27 def initialize(type, expression) @type = type.to_sym @expression = expression end |
Instance Attribute Details
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
25 26 27 |
# File 'lib/yadm/criteria/order.rb', line 25 def expression @expression end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
25 26 27 |
# File 'lib/yadm/criteria/order.rb', line 25 def type @type end |
Instance Method Details
#==(other) ⇒ Object
40 41 42 43 44 |
# File 'lib/yadm/criteria/order.rb', line 40 def ==(other) %i(type expression).all? do |method| other.respond_to?(method) && send(method) == other.send(method) end end |
#asc? ⇒ Boolean
32 33 34 |
# File 'lib/yadm/criteria/order.rb', line 32 def asc? type == :asc end |
#desc? ⇒ Boolean
36 37 38 |
# File 'lib/yadm/criteria/order.rb', line 36 def desc? type == :desc end |