Class: Collate::Sorter

Inherits:
Object
  • Object
show all
Defined in:
lib/collate/sorter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_labelObject

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_nameObject

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

#defaultObject

Returns the value of attribute default.



3
4
5
# File 'lib/collate/sorter.rb', line 3

def default
  @default
end

#desc_labelObject

Returns the value of attribute desc_label.



3
4
5
# File 'lib/collate/sorter.rb', line 3

def desc_label
  @desc_label
end

#fieldObject

Returns the value of attribute field.



3
4
5
# File 'lib/collate/sorter.rb', line 3

def field
  @field
end

#field_selectObject

Returns the value of attribute field_select.



3
4
5
# File 'lib/collate/sorter.rb', line 3

def field_select
  @field_select
end

#joinsObject

Returns the value of attribute joins.



3
4
5
# File 'lib/collate/sorter.rb', line 3

def joins
  @joins
end

#labelObject

Returns the value of attribute label.



3
4
5
# File 'lib/collate/sorter.rb', line 3

def label
  @label
end

#nulls_firstObject

Returns the value of attribute nulls_first.



3
4
5
# File 'lib/collate/sorter.rb', line 3

def nulls_first
  @nulls_first
end

#nulls_lastObject

Returns the value of attribute nulls_last.



3
4
5
# File 'lib/collate/sorter.rb', line 3

def nulls_last
  @nulls_last
end