Class: Collate::Sorter
- Inherits:
-
Object
- Object
- Collate::Sorter
- Defined in:
- lib/collate/sorter.rb
Instance Attribute Summary collapse
-
#asc_label ⇒ Object
Returns the value of attribute asc_label.
-
#base_model_table_name ⇒ Object
Returns the value of attribute base_model_table_name.
-
#default ⇒ Object
Returns the value of attribute default.
-
#desc_label ⇒ Object
Returns the value of attribute desc_label.
-
#field ⇒ Object
Returns the value of attribute field.
-
#field_select ⇒ Object
Returns the value of attribute field_select.
-
#joins ⇒ Object
Returns the value of attribute joins.
-
#label ⇒ Object
Returns the value of attribute label.
-
#nulls_first ⇒ Object
Returns the value of attribute nulls_first.
-
#nulls_last ⇒ Object
Returns the value of attribute nulls_last.
Instance Method Summary collapse
-
#initialize(field, opt = {}) ⇒ Sorter
constructor
A new instance of Sorter.
Constructor Details
#initialize(field, opt = {}) ⇒ Sorter
Returns a new instance of Sorter.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/collate/sorter.rb', line 6 def initialize(field, opt={}) opt.each do |f, value| self.send("#{f}=", value) end self.field = field self.label ||= self.field.to_s.titleize self.asc_label ||= "#{label} ⬇" self.desc_label ||= "#{label} ⬆" self.field = "#{base_model_table_name}.#{field}" if field.is_a? Symbol self.joins ||= [] end |
Instance Attribute Details
#asc_label ⇒ Object
Returns the value of attribute asc_label.
3 4 5 |
# File 'lib/collate/sorter.rb', line 3 def asc_label @asc_label end |
#base_model_table_name ⇒ Object
Returns the value of attribute base_model_table_name.
3 4 5 |
# File 'lib/collate/sorter.rb', line 3 def base_model_table_name @base_model_table_name end |
#default ⇒ Object
Returns the value of attribute default.
3 4 5 |
# File 'lib/collate/sorter.rb', line 3 def default @default end |
#desc_label ⇒ Object
Returns the value of attribute desc_label.
3 4 5 |
# File 'lib/collate/sorter.rb', line 3 def desc_label @desc_label end |
#field ⇒ Object
Returns the value of attribute field.
3 4 5 |
# File 'lib/collate/sorter.rb', line 3 def field @field end |
#field_select ⇒ Object
Returns the value of attribute field_select.
3 4 5 |
# File 'lib/collate/sorter.rb', line 3 def field_select @field_select end |
#joins ⇒ Object
Returns the value of attribute joins.
3 4 5 |
# File 'lib/collate/sorter.rb', line 3 def joins @joins end |
#label ⇒ Object
Returns the value of attribute label.
3 4 5 |
# File 'lib/collate/sorter.rb', line 3 def label @label end |
#nulls_first ⇒ Object
Returns the value of attribute nulls_first.
3 4 5 |
# File 'lib/collate/sorter.rb', line 3 def nulls_first @nulls_first end |
#nulls_last ⇒ Object
Returns the value of attribute nulls_last.
3 4 5 |
# File 'lib/collate/sorter.rb', line 3 def nulls_last @nulls_last end |