Class: ActsAsTable::ColumnModel
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ActsAsTable::ColumnModel
- Defined in:
- app/models/acts_as_table/column_model.rb
Overview
ActsAsTable column model.
Instance Attribute Summary collapse
-
#name ⇒ String
Returns the name for this ActsAsTable column model.
-
#position ⇒ Integer
Returns the position of this ActsAsTable column model.
-
#separator ⇒ String
Returns the separator for the name of this ActsAsTable column model.
Belongs to collapse
-
#row_model ⇒ ActsAsTable::RowModel
Returns the ActsAsTable row model for this ActsAsTable column model.
Has many collapse
-
#foreign_keys ⇒ ActiveRecord::Relation<ActsAsTable::ForeignKey>
Returns the ActsAsTable foreign keys for this ActsAsTable column model.
-
#lenses ⇒ ActiveRecord::Relation<ActsAsTable::Lense>
Returns the ActsAsTable attribute accessors for this ActsAsTable column model.
-
#primary_keys ⇒ ActiveRecord::Relation<ActsAsTable::PrimaryKey>
Returns the ActsAsTable primary keys for this ActsAsTable column model.
-
#values ⇒ ActiveRecord::Relation<ActsAsTable::Value>
Returns the ActsAsTable values that have been provided by this ActsAsTable column model.
Instance Attribute Details
#name ⇒ String
Returns the name for this ActsAsTable column model.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/models/acts_as_table/column_model.rb', line 16 class ColumnModel < ::ActiveRecord::Base # @!parse # include ActsAsTable::ValueProvider # include ActsAsTable::ValueProviderAssociationMethods self.table_name = ActsAsTable.column_models_table # Returns the ActsAsTable row model for this ActsAsTable column model. belongs_to :row_model, **{ class_name: 'ActsAsTable::RowModel', inverse_of: :column_models, required: true, } # Returns the ActsAsTable foreign keys for this ActsAsTable column model. has_many :foreign_keys, **{ autosave: true, class_name: 'ActsAsTable::ForeignKey', dependent: :nullify, foreign_key: 'column_model_id', inverse_of: :column_model, validate: true, } # Returns the ActsAsTable attribute accessors for this ActsAsTable column model. has_many :lenses, **{ autosave: true, class_name: 'ActsAsTable::Lense', dependent: :nullify, foreign_key: 'column_model_id', inverse_of: :column_model, validate: true, } # Returns the ActsAsTable primary keys for this ActsAsTable column model. has_many :primary_keys, **{ autosave: true, class_name: 'ActsAsTable::PrimaryKey', dependent: :nullify, foreign_key: 'column_model_id', inverse_of: :column_model, validate: true, } # Returns the ActsAsTable values that have been provided by this ActsAsTable column model. has_many :values, **{ class_name: 'ActsAsTable::Value', dependent: :restrict_with_exception, foreign_key: 'column_model_id', inverse_of: :column_model, } validates :name, **{ presence: true, } validates :position, **{ numericality: { greater_than_or_equal_to: 1, only_integer: true, }, presence: true, uniqueness: { scope: ['row_model_id'], }, } validates :separator, **{ length: { minimum: 1, }, } end |
#position ⇒ Integer
Returns the position of this ActsAsTable column model.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/models/acts_as_table/column_model.rb', line 16 class ColumnModel < ::ActiveRecord::Base # @!parse # include ActsAsTable::ValueProvider # include ActsAsTable::ValueProviderAssociationMethods self.table_name = ActsAsTable.column_models_table # Returns the ActsAsTable row model for this ActsAsTable column model. belongs_to :row_model, **{ class_name: 'ActsAsTable::RowModel', inverse_of: :column_models, required: true, } # Returns the ActsAsTable foreign keys for this ActsAsTable column model. has_many :foreign_keys, **{ autosave: true, class_name: 'ActsAsTable::ForeignKey', dependent: :nullify, foreign_key: 'column_model_id', inverse_of: :column_model, validate: true, } # Returns the ActsAsTable attribute accessors for this ActsAsTable column model. has_many :lenses, **{ autosave: true, class_name: 'ActsAsTable::Lense', dependent: :nullify, foreign_key: 'column_model_id', inverse_of: :column_model, validate: true, } # Returns the ActsAsTable primary keys for this ActsAsTable column model. has_many :primary_keys, **{ autosave: true, class_name: 'ActsAsTable::PrimaryKey', dependent: :nullify, foreign_key: 'column_model_id', inverse_of: :column_model, validate: true, } # Returns the ActsAsTable values that have been provided by this ActsAsTable column model. has_many :values, **{ class_name: 'ActsAsTable::Value', dependent: :restrict_with_exception, foreign_key: 'column_model_id', inverse_of: :column_model, } validates :name, **{ presence: true, } validates :position, **{ numericality: { greater_than_or_equal_to: 1, only_integer: true, }, presence: true, uniqueness: { scope: ['row_model_id'], }, } validates :separator, **{ length: { minimum: 1, }, } end |
#separator ⇒ String
Returns the separator for the name of this ActsAsTable column model. By default, this is ,
.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/models/acts_as_table/column_model.rb', line 16 class ColumnModel < ::ActiveRecord::Base # @!parse # include ActsAsTable::ValueProvider # include ActsAsTable::ValueProviderAssociationMethods self.table_name = ActsAsTable.column_models_table # Returns the ActsAsTable row model for this ActsAsTable column model. belongs_to :row_model, **{ class_name: 'ActsAsTable::RowModel', inverse_of: :column_models, required: true, } # Returns the ActsAsTable foreign keys for this ActsAsTable column model. has_many :foreign_keys, **{ autosave: true, class_name: 'ActsAsTable::ForeignKey', dependent: :nullify, foreign_key: 'column_model_id', inverse_of: :column_model, validate: true, } # Returns the ActsAsTable attribute accessors for this ActsAsTable column model. has_many :lenses, **{ autosave: true, class_name: 'ActsAsTable::Lense', dependent: :nullify, foreign_key: 'column_model_id', inverse_of: :column_model, validate: true, } # Returns the ActsAsTable primary keys for this ActsAsTable column model. has_many :primary_keys, **{ autosave: true, class_name: 'ActsAsTable::PrimaryKey', dependent: :nullify, foreign_key: 'column_model_id', inverse_of: :column_model, validate: true, } # Returns the ActsAsTable values that have been provided by this ActsAsTable column model. has_many :values, **{ class_name: 'ActsAsTable::Value', dependent: :restrict_with_exception, foreign_key: 'column_model_id', inverse_of: :column_model, } validates :name, **{ presence: true, } validates :position, **{ numericality: { greater_than_or_equal_to: 1, only_integer: true, }, presence: true, uniqueness: { scope: ['row_model_id'], }, } validates :separator, **{ length: { minimum: 1, }, } end |
Instance Method Details
#foreign_keys ⇒ ActiveRecord::Relation<ActsAsTable::ForeignKey>
Returns the ActsAsTable foreign keys for this ActsAsTable column model.
31 32 33 34 35 36 37 38 |
# File 'app/models/acts_as_table/column_model.rb', line 31 has_many :foreign_keys, **{ autosave: true, class_name: 'ActsAsTable::ForeignKey', dependent: :nullify, foreign_key: 'column_model_id', inverse_of: :column_model, validate: true, } |
#lenses ⇒ ActiveRecord::Relation<ActsAsTable::Lense>
Returns the ActsAsTable attribute accessors for this ActsAsTable column model.
41 42 43 44 45 46 47 48 |
# File 'app/models/acts_as_table/column_model.rb', line 41 has_many :lenses, **{ autosave: true, class_name: 'ActsAsTable::Lense', dependent: :nullify, foreign_key: 'column_model_id', inverse_of: :column_model, validate: true, } |
#primary_keys ⇒ ActiveRecord::Relation<ActsAsTable::PrimaryKey>
Returns the ActsAsTable primary keys for this ActsAsTable column model.
51 52 53 54 55 56 57 58 |
# File 'app/models/acts_as_table/column_model.rb', line 51 has_many :primary_keys, **{ autosave: true, class_name: 'ActsAsTable::PrimaryKey', dependent: :nullify, foreign_key: 'column_model_id', inverse_of: :column_model, validate: true, } |
#row_model ⇒ ActsAsTable::RowModel
Returns the ActsAsTable row model for this ActsAsTable column model.
24 25 26 27 28 |
# File 'app/models/acts_as_table/column_model.rb', line 24 belongs_to :row_model, **{ class_name: 'ActsAsTable::RowModel', inverse_of: :column_models, required: true, } |
#values ⇒ ActiveRecord::Relation<ActsAsTable::Value>
Returns the ActsAsTable values that have been provided by this ActsAsTable column model.
61 62 63 64 65 66 |
# File 'app/models/acts_as_table/column_model.rb', line 61 has_many :values, **{ class_name: 'ActsAsTable::Value', dependent: :restrict_with_exception, foreign_key: 'column_model_id', inverse_of: :column_model, } |