Class: Tablets::Tablet

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

Overview

Incapsulates tablet related information.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ Tablet

Initializes tablet with name, callbacks fed with block.



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

def initialize(name, &block)
  @name = name
  @config = Tablets::Utils::Config.new(&block)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/tablets/tablet.rb', line 6

def name
  @name
end

Instance Method Details

#authorize(controller) ⇒ Object

Determines is user authorized. By default returns true.



22
23
24
# File 'lib/tablets/tablet.rb', line 22

def authorize(controller)
  call(:authorize, controller) { true }
end

#columnsObject

Returns columns definitions. Required.



45
46
47
# File 'lib/tablets/tablet.rb', line 45

def columns
  call(:columns)
end

#details(record) ⇒ Object

Returns details HTML for the record. By default returns nil.



34
35
36
# File 'lib/tablets/tablet.rb', line 34

def details(record)
  call(:details, record) { nil }
end

#details?Boolean

Checks if details is defined.

Returns:

  • (Boolean)


39
40
41
# File 'lib/tablets/tablet.rb', line 39

def details?
  has?(:details)
end

#optionsObject

Returns general jquery-datatable configuration overrides. By default returns empty options.



16
17
18
# File 'lib/tablets/tablet.rb', line 16

def options
  call(:options) { {} }
end

#process(records) ⇒ Object

Allows to make additional processing before records would be used. By default returns records.



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

def process(records)
  call(:process, records) { records }
end

#relation(params) ⇒ Object

Returns database relation to fetch data. Required.



51
52
53
# File 'lib/tablets/tablet.rb', line 51

def relation(params)
  call(:relation, params)
end