Class: Tablets::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/tablets/base.rb

Overview

Incapsulates tablet related information

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.inherited(child_class) ⇒ Object



4
5
6
7
# File 'lib/tablets/base.rb', line 4

def self.inherited(child_class)
  tablet_name = child_class.tablet_name
  Tablets.register_tablet(tablet_name, child_class)
end

.tablet_nameObject



9
10
11
# File 'lib/tablets/base.rb', line 9

def self.tablet_name
  name.underscore.sub(/_tablet$/, '')
end

Instance Method Details

#authorize(controller) ⇒ Object

Determines is user authorized



23
24
25
# File 'lib/tablets/base.rb', line 23

def authorize(controller)
  true
end

#columnsObject

Returns columns definitions



38
39
40
# File 'lib/tablets/base.rb', line 38

def columns
  deduct_columns_from_relation
end

#details(record) ⇒ Object

Returns details HTML for the record



33
34
35
# File 'lib/tablets/base.rb', line 33

def details(record)
  nil
end

#nameObject



13
14
15
# File 'lib/tablets/base.rb', line 13

def name
  self.class.tablet_name
end

#optionsObject

Returns general jquery-datatable configuration overrides



18
19
20
# File 'lib/tablets/base.rb', line 18

def options
  {}
end

#payloadObject

Returns additional data returned to client



48
49
50
# File 'lib/tablets/base.rb', line 48

def payload
  {}
end

#process(records) ⇒ Object

Allows to make additional processing before records would be used



28
29
30
# File 'lib/tablets/base.rb', line 28

def process(records)
  records
end

#relation(options = {}) ⇒ Object

Returns database relation to fetch data



43
44
45
# File 'lib/tablets/base.rb', line 43

def relation(options = {})
  name.camelize.constantize.where(nil)
end