Module: TableSortable::Controller

Extended by:
ActiveSupport::Concern
Defined in:
lib/table_sortable/controller.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#column_offsetObject (readonly)

Returns the value of attribute column_offset.



129
130
131
# File 'lib/table_sortable/controller.rb', line 129

def column_offset
  @column_offset
end

#column_orderObject (readonly)

Returns the value of attribute column_order.



129
130
131
# File 'lib/table_sortable/controller.rb', line 129

def column_order
  @column_order
end

#template_pathObject (readonly)

Returns the value of attribute template_path.



129
130
131
# File 'lib/table_sortable/controller.rb', line 129

def template_path
  @template_path
end

#translation_keyObject (readonly)

Returns the value of attribute translation_key.



129
130
131
# File 'lib/table_sortable/controller.rb', line 129

def translation_key
  @translation_key
end

Instance Method Details

#columnsObject



87
88
89
# File 'lib/table_sortable/controller.rb', line 87

def columns
  @columns.sort_by(column_order)
end

#define_column(col_name, *options) ⇒ Object



66
67
68
69
# File 'lib/table_sortable/controller.rb', line 66

def define_column(col_name, *options)
  options = default_column_options.merge(options.extract_options!)
  @columns.add(col_name, options.merge(controller: self))
end

#define_column_offset(offset) ⇒ Object



75
76
77
# File 'lib/table_sortable/controller.rb', line 75

def define_column_offset(offset)
  @column_offset = offset
end

#define_column_order(*order) ⇒ Object



71
72
73
# File 'lib/table_sortable/controller.rb', line 71

def define_column_order(*order)
  @column_order = order
end

#define_columns(*args) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/table_sortable/controller.rb', line 52

def define_columns(*args)
  options = args.extract_options!
  column_offset = options[:offset] || 0
  translation_key = options[:translation_key]
  template_path = options[:template_path]
  columns   = args
  define_translation_key translation_key
  define_template_path template_path
  define_column_offset column_offset
  columns.each do |column|
    define_column column, translation_key: translation_key
  end
end

#define_template_path(path) ⇒ Object



83
84
85
# File 'lib/table_sortable/controller.rb', line 83

def define_template_path(path)
  @template_path = path.blank? ? nil : File.join(path, "")
end

#define_translation_key(key) ⇒ Object



79
80
81
# File 'lib/table_sortable/controller.rb', line 79

def define_translation_key(key)
  @translation_key = key
end