Module: Clevic::OrderedDataset
- Included in:
- CacheTable, TableSearcher
- Defined in:
- lib/clevic/ordered_dataset.rb
Overview
Provides a nice way of getting to Sequel::Dataset’s opts information
Including class must call dataset= before calling order_attributes
Instance Attribute Summary collapse
-
#dataset ⇒ Object
Returns the value of attribute dataset.
Instance Method Summary collapse
-
#order_attributes ⇒ Object
returns a collection of [ attribute, (1|-1) ] where 1 is forward/asc (>) and -1 is backward/desc (<).
Instance Attribute Details
#dataset ⇒ Object
Returns the value of attribute dataset.
30 31 32 |
# File 'lib/clevic/ordered_dataset.rb', line 30 def dataset @dataset end |
Instance Method Details
#order_attributes ⇒ Object
returns a collection of [ attribute, (1|-1) ] where 1 is forward/asc (>) and -1 is backward/desc (<)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/clevic/ordered_dataset.rb', line 11 def order_attributes if @order_attributes.nil? @order_attributes = dataset.opts[:order].map do |order_expr| case order_expr when Symbol [ order_expr, 1 ] when Sequel::SQL::OrderedExpression [ order_expr.expression, order_expr.descending ? -1 : 1 ] else raise "unknown order_expr: #{order_expr.inspect}" end end end @order_attributes end |