class AjaxDatatablesRails::Datatable::Datatable
Attributes
options[R]
Public Class Methods
new(datatable)
click to toggle source
# File lib/ajax-datatables-rails/datatable/datatable.rb, line 8 def initialize(datatable) @datatable = datatable @options = datatable.params end
Public Instance Methods
column_by(how, what)
click to toggle source
# File lib/ajax-datatables-rails/datatable/datatable.rb, line 47 def column_by(how, what) columns.find { |simple_column| simple_column.send(how) == what } end
columns()
click to toggle source
—————– COLUMN METHODS ——————–
# File lib/ajax-datatables-rails/datatable/datatable.rb, line 41 def columns @columns ||= get_param(:columns).map do |index, column_options| Column.new(@datatable, index, column_options) end end
db_adapter()
click to toggle source
# File lib/ajax-datatables-rails/datatable/datatable.rb, line 81 def db_adapter @datatable.db_adapter end
get_param(param)
click to toggle source
# File lib/ajax-datatables-rails/datatable/datatable.rb, line 69 def get_param(param) return {} if options[param].nil? if options[param].is_a? Array hash = {} options[param].each_with_index { |value, index| hash[index] = value } hash else options[param].to_unsafe_h.with_indifferent_access end end
nulls_last()
click to toggle source
# File lib/ajax-datatables-rails/datatable/datatable.rb, line 85 def nulls_last @datatable.nulls_last end
offset()
click to toggle source
# File lib/ajax-datatables-rails/datatable/datatable.rb, line 61 def offset options.fetch(:start, 0).to_i end
order_by(how, what)
click to toggle source
# File lib/ajax-datatables-rails/datatable/datatable.rb, line 25 def order_by(how, what) orders.find { |simple_order| simple_order.send(how) == what } end
orderable?()
click to toggle source
—————– ORDER METHODS ——————–
# File lib/ajax-datatables-rails/datatable/datatable.rb, line 15 def orderable? options[:order].present? end
orders()
click to toggle source
# File lib/ajax-datatables-rails/datatable/datatable.rb, line 19 def orders @orders ||= get_param(:order).map do |_, order_options| SimpleOrder.new(self, order_options) end end
page()
click to toggle source
# File lib/ajax-datatables-rails/datatable/datatable.rb, line 65 def page (offset / per_page) + 1 end
paginate?()
click to toggle source
—————– OPTIONS METHODS ——————–
# File lib/ajax-datatables-rails/datatable/datatable.rb, line 53 def paginate? per_page != -1 end
per_page()
click to toggle source
# File lib/ajax-datatables-rails/datatable/datatable.rb, line 57 def per_page options.fetch(:length, 10).to_i end
search()
click to toggle source
# File lib/ajax-datatables-rails/datatable/datatable.rb, line 35 def search @search ||= SimpleSearch.new(options[:search]) end
searchable?()
click to toggle source
—————– SEARCH METHODS ——————–
# File lib/ajax-datatables-rails/datatable/datatable.rb, line 31 def searchable? options[:search].present? && options[:search][:value].present? end