Class: Nitron::UI::DataBoundTableDelegate

Inherits:
Object
  • Object
show all
Defined in:
lib/nitron/ui/data_bound_table_delegate.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



12
13
14
15
16
17
18
# File 'lib/nitron/ui/data_bound_table_delegate.rb', line 12

def method_missing(method, *args, &block)
  if @delegate
    @delegate.send(method, *args, &block)
  else
    super
  end
end

Instance Method Details

#initWithDelegate(delegate) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/nitron/ui/data_bound_table_delegate.rb', line 4

def initWithDelegate(delegate)
  if init
    @delegate = delegate
  end

  self
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
28
# File 'lib/nitron/ui/data_bound_table_delegate.rb', line 20

def respond_to?(method)
  if method == "tableView:willDisplayCell:forRowAtIndexPath"
    true
  elsif @delegate
    @delegate.respond_to?(method)
  else
    super
  end
end

#tableView(tableView, willDisplayCell: cell, forRowAtIndexPath: indexPath) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/nitron/ui/data_bound_table_delegate.rb', line 30

def tableView(tableView, willDisplayCell:cell, forRowAtIndexPath:indexPath)
  if @delegate && @delegate.respond_to?("tableView:willDisplayCell:forRowAtIndexPath:")
    @delegate.tableView(tableView, willDisplayCell:cell, forRowAtIndexPath:indexPath)
  end

  model = tableView.dataSource.objectAtIndexPath(indexPath)

  Nitron::UI::DataBinder.shared.bind(model, cell)
end