Class: Rose::Attribute::Sort
- Inherits:
-
Object
- Object
- Rose::Attribute::Sort
- Defined in:
- lib/rose/attribute.rb
Overview
This is a value object for sort parameters
Instance Attribute Summary collapse
-
#column_name ⇒ Object
readonly
Returns the value of attribute column_name.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#sort_block ⇒ Object
readonly
Returns the value of attribute sort_block.
Instance Method Summary collapse
-
#initialize(column_name, order, &sort_block) ⇒ Sort
constructor
A new instance of Sort.
- #on(table) ⇒ Object
Constructor Details
#initialize(column_name, order, &sort_block) ⇒ Sort
Returns a new instance of Sort.
67 68 69 70 71 |
# File 'lib/rose/attribute.rb', line 67 def initialize(column_name, order, &sort_block) @column_name = column_name @order = order @sort_block = sort_block end |
Instance Attribute Details
#column_name ⇒ Object (readonly)
Returns the value of attribute column_name.
65 66 67 |
# File 'lib/rose/attribute.rb', line 65 def column_name @column_name end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
65 66 67 |
# File 'lib/rose/attribute.rb', line 65 def order @order end |
#sort_block ⇒ Object (readonly)
Returns the value of attribute sort_block.
65 66 67 |
# File 'lib/rose/attribute.rb', line 65 def sort_block @sort_block end |
Instance Method Details
#on(table) ⇒ Object
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/rose/attribute.rb', line 73 def on(table) if @sort_block table.sort_rows_by!(nil, :order => @order) do |row| @sort_block.call(row[@column_name]) end else table.sort_rows_by!(@column_name, :order => @order) end table end |