Module: DataTablesController

Defined in:
lib/data_tables.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(cls) ⇒ Object



4
5
6
# File 'lib/data_tables.rb', line 4

def self.included(cls)
  cls.extend(ClassMethods)
end

Instance Method Details

#datatable_source(name) ⇒ Object



397
398
399
# File 'lib/data_tables.rb', line 397

def datatable_source(name)
  {:action => name, :attrs => method("datatable_#{name}_columns".to_sym).call}
end

#datatables_instance_get_value(instance, column) ⇒ Object

gets the value for a column and row



379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
# File 'lib/data_tables.rb', line 379

def datatables_instance_get_value(instance, column)
  if column[:special]
    special = column[:special]

    if special[:method]
      return method(special[:method].to_sym).call(instance)
    elsif special[:eval]
      proc = lambda { obj = instance; binding }
      return Kernel.eval(special[:eval], proc.call)
    end
  elsif column[:attribute]
    val = instance.send(column[:attribute].to_sym)
    return I18n.t(val.to_s.to_sym, :default => val.to_s) if not val.blank?
    return ''
  end
  return "value not found"
end