Class: ProMotion::DataTableScreen

Inherits:
TableScreen show all
Defined in:
lib/project/pro_motion/data_table_screen.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.data_modelObject



13
# File 'lib/project/pro_motion/data_table_screen.rb', line 13

def data_model; @data_model; end

.data_scopeObject



14
# File 'lib/project/pro_motion/data_table_screen.rb', line 14

def data_scope; @data_scope; end

.model(value, scope = nil) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/project/pro_motion/data_table_screen.rb', line 4

def model(value, scope=nil)
  if value.method_defined?(:cell)
    @data_model = value
    @data_scope = scope || :all
  else
    raise "#{value} must define the cell method"
  end
end

Instance Method Details

#cell_dataObject



23
24
25
26
27
# File 'lib/project/pro_motion/data_table_screen.rb', line 23

def cell_data
  return [] if data_model.nil?

  data_model.send(data_scope).collect(&:cell)
end

#table_dataObject



17
18
19
20
21
# File 'lib/project/pro_motion/data_table_screen.rb', line 17

def table_data
  [{
    cells: cell_data
  }]
end