Class: DataTable
- Inherits:
-
Object
- Object
- DataTable
- Defined in:
- app/models/data_table.rb
Instance Attribute Summary collapse
-
#allowed_controller_actions ⇒ Object
(also: #controller_actions)
readonly
Returns the value of attribute allowed_controller_actions.
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#new_record_strategy ⇒ Object
readonly
Returns the value of attribute new_record_strategy.
Class Method Summary collapse
Instance Method Summary collapse
- #class_name ⇒ Object
- #classify ⇒ Object
- #controller_name ⇒ Object
- #controllerify ⇒ Object
-
#initialize(name, columns, options = {}) ⇒ DataTable
constructor
A new instance of DataTable.
Constructor Details
#initialize(name, columns, options = {}) ⇒ DataTable
Returns a new instance of DataTable.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/data_table.rb', line 13 def initialize(name, columns, = {}) @name = name @columns = columns @new_record_strategy = [:new_record_strategy] || :insert [:allowed_controller_actions] ||= [:controller_actions] if [:allowed_controller_actions].present? @allowed_controller_actions = Array([:allowed_controller_actions]).map(&:to_sym) else @allowed_controller_actions = legacy_controller_actions end self.class.all[name.to_sym] = self end |
Instance Attribute Details
#allowed_controller_actions ⇒ Object (readonly) Also known as: controller_actions
Returns the value of attribute allowed_controller_actions.
10 11 12 |
# File 'app/models/data_table.rb', line 10 def allowed_controller_actions @allowed_controller_actions end |
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
10 11 12 |
# File 'app/models/data_table.rb', line 10 def columns @columns end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'app/models/data_table.rb', line 10 def name @name end |
#new_record_strategy ⇒ Object (readonly)
Returns the value of attribute new_record_strategy.
10 11 12 |
# File 'app/models/data_table.rb', line 10 def new_record_strategy @new_record_strategy end |
Class Method Details
.all ⇒ Object
2 3 4 |
# File 'app/models/data_table.rb', line 2 def self.all @all ||= {} end |
.find_by_name(name) ⇒ Object
6 7 8 |
# File 'app/models/data_table.rb', line 6 def self.find_by_name(name) all[name.to_sym] end |
Instance Method Details
#class_name ⇒ Object
26 27 28 |
# File 'app/models/data_table.rb', line 26 def class_name name.to_s.classify end |
#classify ⇒ Object
34 35 36 37 38 39 |
# File 'app/models/data_table.rb', line 34 def classify return Gatherable.const_get(class_name) if Gatherable.const_defined?(class_name) klass = Gatherable.const_set(class_name, Class.new(ActiveRecord::Base)) klass.table_name = Gatherable.config.schema_name + '.' + name.to_s.pluralize klass end |
#controller_name ⇒ Object
30 31 32 |
# File 'app/models/data_table.rb', line 30 def controller_name "#{class_name.pluralize}Controller" end |
#controllerify ⇒ Object
41 42 43 44 |
# File 'app/models/data_table.rb', line 41 def controllerify return Gatherable.const_get(controller_name) if Gatherable.const_defined?(controller_name) Gatherable.const_set(controller_name, Class.new(Gatherable::ApplicationController)) end |