Class: AjaxDatatablesRails::AltApi::Datatable::RowContext
- Inherits:
-
Object
- Object
- AjaxDatatablesRails::AltApi::Datatable::RowContext
- Defined in:
- lib/ajax-datatables-rails/alt-api/datatable/row_context.rb
Overview
This is used by the column.cell_renderer and seamlessly delegates to the view or the record
Instance Attribute Summary collapse
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#view ⇒ Object
readonly
Returns the value of attribute view.
Instance Method Summary collapse
-
#initialize(view, record, cell_methods_module = nil) ⇒ RowContext
constructor
A new instance of RowContext.
-
#method_missing(meth, *args) ⇒ Object
This allows seamless delegation to @current_record or @view.
- #respond_to_missing?(meth, _include_all) ⇒ Boolean
Constructor Details
#initialize(view, record, cell_methods_module = nil) ⇒ RowContext
Returns a new instance of RowContext.
9 10 11 12 13 14 |
# File 'lib/ajax-datatables-rails/alt-api/datatable/row_context.rb', line 9 def initialize(view, record, cell_methods_module = nil) self.class.include cell_methods_module if cell_methods_module @view = view @record = record end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
This allows seamless delegation to @current_record or @view
17 18 19 20 21 22 23 24 25 |
# File 'lib/ajax-datatables-rails/alt-api/datatable/row_context.rb', line 17 def method_missing(meth, *args) if @record.respond_to?(meth) @record.send(meth, *args) elsif @view.respond_to?(meth) @view.send(meth, *args) else super end end |
Instance Attribute Details
#record ⇒ Object (readonly)
Returns the value of attribute record.
7 8 9 |
# File 'lib/ajax-datatables-rails/alt-api/datatable/row_context.rb', line 7 def record @record end |
#view ⇒ Object (readonly)
Returns the value of attribute view.
7 8 9 |
# File 'lib/ajax-datatables-rails/alt-api/datatable/row_context.rb', line 7 def view @view end |
Instance Method Details
#respond_to_missing?(meth, _include_all) ⇒ Boolean
27 28 29 |
# File 'lib/ajax-datatables-rails/alt-api/datatable/row_context.rb', line 27 def respond_to_missing?(meth, _include_all) @record.respond_to?(meth) || @view.respond_to?(meth) || super end |