Class: YADM::Criteria::Order::Clause

Inherits:
Object
  • Object
show all
Defined in:
lib/yadm/criteria/order.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#expressionObject (readonly)

Returns the value of attribute expression.



25
26
27
# File 'lib/yadm/criteria/order.rb', line 25

def expression
  @expression
end

#typeObject (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

Returns:

  • (Boolean)


32
33
34
# File 'lib/yadm/criteria/order.rb', line 32

def asc?
  type == :asc
end

#desc?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/yadm/criteria/order.rb', line 36

def desc?
  type == :desc
end