Class: ActiveRecord::Materialized::CacheTableSchema::ColumnDefinition Private
- Inherits:
-
Data
- Object
- Data
- ActiveRecord::Materialized::CacheTableSchema::ColumnDefinition
- Defined in:
- lib/activerecord/materialized/cache_table_schema.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
An inferred cache-table column: name from the relation projection, a create_table
column type, and — for a :decimal — the precision/scale that preserve value
fidelity (a bare decimal is DECIMAL(10,0) on MySQL, which truncates).
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#precision ⇒ Object
readonly
Returns the value of attribute precision.
-
#scale ⇒ Object
readonly
Returns the value of attribute scale.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(name:, type:, precision: nil, scale: nil) ⇒ ColumnDefinition
constructor
private
A new instance of ColumnDefinition.
-
#migration_arguments ⇒ Object
private
The trailing arguments for a
t.<type> :<name>migration line ("" when none). -
#options ⇒ Object
private
create_table options for this column (precision/scale for a decimal; none otherwise).
Constructor Details
#initialize(name:, type:, precision: nil, scale: nil) ⇒ ColumnDefinition
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ColumnDefinition.
15 |
# File 'lib/activerecord/materialized/cache_table_schema.rb', line 15 def initialize(name:, type:, precision: nil, scale: nil) = super |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name
14 15 16 |
# File 'lib/activerecord/materialized/cache_table_schema.rb', line 14 def name @name end |
#precision ⇒ Object (readonly)
Returns the value of attribute precision
14 15 16 |
# File 'lib/activerecord/materialized/cache_table_schema.rb', line 14 def precision @precision end |
#scale ⇒ Object (readonly)
Returns the value of attribute scale
14 15 16 |
# File 'lib/activerecord/materialized/cache_table_schema.rb', line 14 def scale @scale end |
#type ⇒ Object (readonly)
Returns the value of attribute type
14 15 16 |
# File 'lib/activerecord/materialized/cache_table_schema.rb', line 14 def type @type end |
Instance Method Details
#migration_arguments ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The trailing arguments for a t.<type> :<name> migration line ("" when none).
23 24 25 |
# File 'lib/activerecord/materialized/cache_table_schema.rb', line 23 def migration_arguments .map { |key, value| ", #{key}: #{value}" }.join end |
#options ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
create_table options for this column (precision/scale for a decimal; none otherwise).
18 19 20 |
# File 'lib/activerecord/materialized/cache_table_schema.rb', line 18 def { precision: precision, scale: scale }.compact end |