class Tablets::Base
Incapsulates tablet related information
Public Class Methods
inherited(child_class)
click to toggle source
# 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()
click to toggle source
# File lib/tablets/base.rb, line 9 def self.tablet_name name.underscore.sub(/_tablet$/, '') end
Public Instance Methods
columns()
click to toggle source
Returns columns definitions
# File lib/tablets/base.rb, line 38 def columns deduct_columns_from_relation end
details(record)
click to toggle source
Returns details HTML for the record
# File lib/tablets/base.rb, line 33 def details(record) nil end
name()
click to toggle source
# File lib/tablets/base.rb, line 13 def name self.class.tablet_name end
options()
click to toggle source
Returns general jquery-datatable configuration overrides
# File lib/tablets/base.rb, line 18 def options {} end
payload()
click to toggle source
Returns additional data returned to client
# File lib/tablets/base.rb, line 48 def payload {} end
process(records)
click to toggle source
Allows to make additional processing before records would be used
# File lib/tablets/base.rb, line 28 def process(records) records end
relation(options = {})
click to toggle source
Returns database relation to fetch data
# File lib/tablets/base.rb, line 43 def relation(options = {}) name.camelize.constantize.where(nil) end
Private Instance Methods
deduct_columns_from_relation()
click to toggle source
Returns default columns definititions, deducted from relation
# File lib/tablets/base.rb, line 55 def deduct_columns_from_relation relation.columns.map(&:name).map do |name| { title: name.humanize.capitalize, data: name.to_sym, order: name } end end