Class: ActsAsTable::ColumnModel

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/acts_as_table/column_model.rb

Overview

ActsAsTable column model.

Instance Attribute Summary collapse

Belongs to collapse

Has many collapse

Instance Attribute Details

#nameString

Returns the name for this ActsAsTable column model.

Returns:

  • (String)


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

#positionInteger

Returns the position of this ActsAsTable column model.

Returns:

  • (Integer)


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

#separatorString

Returns the separator for the name of this ActsAsTable column model. By default, this is ,.

Returns:

  • (String)


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_keysActiveRecord::Relation<ActsAsTable::ForeignKey>

Returns the ActsAsTable foreign keys for this ActsAsTable column model.

Returns:

See Also:



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,
}

#lensesActiveRecord::Relation<ActsAsTable::Lense>

Returns the ActsAsTable attribute accessors for this ActsAsTable column model.

Returns:

See Also:



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_keysActiveRecord::Relation<ActsAsTable::PrimaryKey>

Returns the ActsAsTable primary keys for this ActsAsTable column model.

Returns:

See Also:



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_modelActsAsTable::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,
}

#valuesActiveRecord::Relation<ActsAsTable::Value>

Returns the ActsAsTable values that have been provided by this ActsAsTable column model.

Returns:

See Also:



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,
}