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
425 426 427 |
# File 'lib/data_tables.rb', line 425 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
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'lib/data_tables.rb', line 403 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 trans = I18n.t(val.to_s.to_sym, :default => val.to_s) return trans.class == String ? trans : val.to_s else return '' end end return "value not found" end |