Module: DataTablesController
- Defined in:
- lib/data_tables.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #datatable_source(name) ⇒ Object
-
#datatables_instance_get_value(instance, column) ⇒ Object
gets the value for a column and row.
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
400 401 402 |
# File 'lib/data_tables.rb', line 400 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 396 397 398 |
# 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) if !val.blank? || val == false return I18n.t(val.to_s.to_sym, :default => val.to_s) else return '' end end return "value not found" end |