Class: Activecube::Query::Ordering
- Inherits:
-
Object
- Object
- Activecube::Query::Ordering
- Defined in:
- lib/activecube/query/ordering.rb
Instance Attribute Summary collapse
-
#argument ⇒ Object
readonly
Returns the value of attribute argument.
-
#direction ⇒ Object
readonly
Returns the value of attribute direction.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #append_query(_model, _cube_query, _table, query) ⇒ Object
-
#initialize(argument, direction, options = {}) ⇒ Ordering
constructor
A new instance of Ordering.
- #quote(s) ⇒ Object
Constructor Details
#initialize(argument, direction, options = {}) ⇒ Ordering
Returns a new instance of Ordering.
6 7 8 9 10 |
# File 'lib/activecube/query/ordering.rb', line 6 def initialize argument, direction, = {} @argument = argument @direction = direction @options = end |
Instance Attribute Details
#argument ⇒ Object (readonly)
Returns the value of attribute argument.
5 6 7 |
# File 'lib/activecube/query/ordering.rb', line 5 def argument @argument end |
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
5 6 7 |
# File 'lib/activecube/query/ordering.rb', line 5 def direction @direction end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/activecube/query/ordering.rb', line 5 def @options end |
Instance Method Details
#append_query(_model, _cube_query, _table, query) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/activecube/query/ordering.rb', line 12 def append_query _model, _cube_query, _table, query @text = argument.to_s.split(',').map{|s| quote s}.join(',') if [:with_length] return by_length_order(query) end simple_order(query) end |
#quote(s) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/activecube/query/ordering.rb', line 22 def quote s if s =~ /^[\w\.]+$/ "`#{s}`" else s end end |