Class: Safrano::Order
- Defined in:
- lib/odata/collection_order.rb
Direct Known Subclasses
Constant Summary
Constants inherited from OrderBase
Safrano::OrderBase::EmptyOrder
Instance Attribute Summary collapse
-
#oarg ⇒ Object
readonly
Returns the value of attribute oarg.
Instance Method Summary collapse
- #apply_to_dataset(dtcx) ⇒ Object
- #build_oarg ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(ostr, jh) ⇒ Order
constructor
A new instance of Order.
Methods inherited from OrderBase
Constructor Details
#initialize(ostr, jh) ⇒ Order
Returns a new instance of Order.
34 35 36 37 38 39 |
# File 'lib/odata/collection_order.rb', line 34 def initialize(ostr, jh) ostr.strip! @orderp = ostr @jh = jh build_oarg if @orderp end |
Instance Attribute Details
#oarg ⇒ Object (readonly)
Returns the value of attribute oarg.
32 33 34 |
# File 'lib/odata/collection_order.rb', line 32 def oarg @oarg end |
Instance Method Details
#apply_to_dataset(dtcx) ⇒ Object
45 46 47 48 49 |
# File 'lib/odata/collection_order.rb', line 45 def apply_to_dataset(dtcx) # Warning, we need order_append, simply order(oarg) overwrites # previous one ! dtcx.order_append(@oarg) end |
#build_oarg ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/odata/collection_order.rb', line 51 def build_oarg field, ord = @orderp.split(' ') oargu = if field.include?('/') @assoc, field = field.split('/') @jh.add @assoc Sequel[@jh.start_model.get_alias_sym(@assoc)][field.strip.to_sym] else Sequel[field.strip.to_sym] end @oarg = if ord == 'desc' Sequel.desc(oargu) else Sequel.asc(oargu) end end |
#empty? ⇒ Boolean
41 42 43 |
# File 'lib/odata/collection_order.rb', line 41 def empty? false end |