Class: Tablets::Base
- Inherits:
-
Object
- Object
- Tablets::Base
- Defined in:
- lib/tablets/base.rb
Overview
Incapsulates tablet related information
Class Method Summary collapse
Instance Method Summary collapse
-
#authorize(controller) ⇒ Object
Determines is user authorized.
-
#columns ⇒ Object
Returns columns definitions.
-
#details(record) ⇒ Object
Returns details HTML for the record.
- #name ⇒ Object
-
#options ⇒ Object
Returns general jquery-datatable configuration overrides.
-
#payload ⇒ Object
Returns additional data returned to client.
-
#process(records) ⇒ Object
Allows to make additional processing before records would be used.
-
#relation(options = {}) ⇒ Object
Returns database relation to fetch data.
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_name ⇒ Object
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 (controller) true end |
#columns ⇒ Object
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 |
#name ⇒ Object
13 14 15 |
# File 'lib/tablets/base.rb', line 13 def name self.class.tablet_name end |
#options ⇒ Object
Returns general jquery-datatable configuration overrides
18 19 20 |
# File 'lib/tablets/base.rb', line 18 def {} end |
#payload ⇒ Object
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( = {}) name.camelize.constantize.where(nil) end |