Method: Effective::DatatableDslTool#method_missing

Defined in:
app/models/effective/datatable_dsl_tool.rb

#method_missing(method, *args, **kwargs, &block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/models/effective/datatable_dsl_tool.rb', line 21

def method_missing(method, *args, **kwargs, &block)
  # Catch a common error
  if [:bulk_actions, :charts, :collection, :filters].include?(method) && in_datatables_do_block
    raise "#{method} block must be declared outside the datatable do ... end block"
  end

  subject = datatable if datatable.respond_to?(method)
  subject ||= view if view.respond_to?(method)
  subject ||= Tenant.helpers if defined?(Tenant) && Tenant.helpers.respond_to?(method)

  return super unless subject

  if block_given?
    subject.send(method, *args, **kwargs) { yield }
  else
    subject.send(method, *args, **kwargs)
  end
end