Class: Safrano::MultiOrder

Inherits:
Order show all
Defined in:
lib/odata/collection_order.rb

Overview

complex ordering logic

Constant Summary

Constants inherited from OrderBase

OrderBase::EmptyOrder

Instance Attribute Summary

Attributes inherited from Order

#oarg

Instance Method Summary collapse

Methods inherited from Order

#build_oarg, #empty?

Methods inherited from OrderBase

#empty?, factory

Constructor Details

#initialize(orderstr, jh) ⇒ MultiOrder

Returns a new instance of MultiOrder.



72
73
74
75
76
77
78
# File 'lib/odata/collection_order.rb', line 72

def initialize(orderstr, jh)
  super
  @olist = []
  @jh = jh
  @orderstr = orderstr.dup
  @olist = orderstr.split(',').map { |ostr| Order.new(ostr, @jh) }
end

Instance Method Details

#apply_to_dataset(dtcx) ⇒ Object



80
81
82
83
# File 'lib/odata/collection_order.rb', line 80

def apply_to_dataset(dtcx)
  @olist.each { |osingl| dtcx = osingl.apply_to_dataset(dtcx) }
  dtcx
end

#parse_error?Boolean

Returns:

  • (Boolean)


85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/odata/collection_order.rb', line 85

def parse_error?
  @orderstr.split(',').each do |pord|
    pord.strip!
    qualfn, dir = pord.split(/\s/)
    qualfn.strip!
    dir.strip! if dir
    return true unless @jh.start_model.attrib_path_valid? qualfn
    return true unless [nil, 'asc', 'desc'].include? dir
  end

  false
end