Class: Handles::SortableColumns::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/handles/sortable_columns.rb

Overview

Sortable columns configuration object. Passed to the block when you do a:

handles_sortable_columns do |conf|
  ...
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Config

Returns a new instance of Config.



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/handles/sortable_columns.rb', line 73

def initialize(attrs = {})
  defaults = {
    :link_class => "SortableColumnLink",
    :indicator_class => {:asc => "SortedAsc", :desc => "SortedDesc"},
    :indicator_text => {:asc => " ↓ ", :desc => " ↑ "},
    :page_param => "page",
    :sort_param => "sort",
    :default_sort_value => nil
  }

  defaults.merge(attrs).each {|k, v| send("#{k}=", v)}
end

Instance Attribute Details

#default_sort_valueObject

Default sort direction, if params is not given.

default_sort_value


61
62
63
# File 'lib/handles/sortable_columns.rb', line 61

def default_sort_value
  @default_sort_value
end

#indicator_classObject

Sort indicator class. Default:

{:asc => "SortedAsc", :desc => "SortedDesc"}


71
72
73
# File 'lib/handles/sortable_columns.rb', line 71

def indicator_class
  @indicator_class
end

#indicator_textObject

Sort indicator text. If any of values are empty, indicator is not displayed. Default:

{:asc => " ↓ ", :desc => " ↑ "}


66
67
68
# File 'lib/handles/sortable_columns.rb', line 66

def indicator_text
  @indicator_text
end

CSS class for link (regardless of sorted state). Default:

SortableColumnLink


46
47
48
# File 'lib/handles/sortable_columns.rb', line 46

def link_class
  @link_class
end

#page_paramObject

GET parameter name for page number. Default:

page


51
52
53
# File 'lib/handles/sortable_columns.rb', line 51

def page_param
  @page_param
end

#sort_paramObject

GET parameter name for sort column and direction. Default:

sort


56
57
58
# File 'lib/handles/sortable_columns.rb', line 56

def sort_param
  @sort_param
end

Instance Method Details

#[](key) ⇒ Object

Bracket access for convenience.



87
88
89
# File 'lib/handles/sortable_columns.rb', line 87

def [](key)
  send(key)
end

#[]=(key, value) ⇒ Object

Bracket access for convenience.



92
93
94
# File 'lib/handles/sortable_columns.rb', line 92

def []=(key, value)
  send("#{key}=", value)
end