Class: Criteria::Order
- Inherits:
-
Object
- Object
- Criteria::Order
- Defined in:
- lib/criteria.rb
Overview
This class reprsents an ordering by a particular column. The normal way to retreive and instance of this object is by calling the direction on the Column instance, e.g. User.email.asc
Constant Summary collapse
- ASC =
"ASC"
- DESC =
"DESC"
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(column, dir = ASC) ⇒ Order
constructor
A new instance of Order.
- #to_s ⇒ Object
Constructor Details
#initialize(column, dir = ASC) ⇒ Order
Returns a new instance of Order.
212 213 214 215 |
# File 'lib/criteria.rb', line 212 def initialize(column, dir = ASC) @column = column @dir = dir end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
208 209 210 |
# File 'lib/criteria.rb', line 208 def column @column end |
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
208 209 210 |
# File 'lib/criteria.rb', line 208 def dir @dir end |
Class Method Details
.asc(col) ⇒ Object
221 222 223 |
# File 'lib/criteria.rb', line 221 def self.asc(col) Order.new(col, ASC) end |
.desc(col) ⇒ Object
225 226 227 |
# File 'lib/criteria.rb', line 225 def self.desc(col) Order.new(col, DESC) end |
Instance Method Details
#to_s ⇒ Object
217 218 219 |
# File 'lib/criteria.rb', line 217 def to_s "#{@column.to_sql_name} #{@dir}" end |