Module: Sequel::Plugins::ClassTableInheritance::ClassMethods
- Defined in:
- lib/sequel/plugins/class_table_inheritance.rb
Instance Attribute Summary collapse
-
#cti_ignore_subclass_columns ⇒ Object
readonly
An array of columns that may be duplicated in sub-classes.
-
#cti_instance_dataset ⇒ Object
readonly
The dataset that table instance datasets are based on.
-
#cti_models ⇒ Object
readonly
An array of each model in the inheritance hierarchy that is backed by a new table.
-
#cti_qualify_tables ⇒ Object
readonly
A boolean indicating whether or not to automatically qualify tables backing subclasses with the same qualifier as their superclass, if the superclass is qualified.
-
#cti_table_columns ⇒ Object
readonly
An array of column symbols for the backing database table, giving the columns to update in each backing database table.
-
#cti_table_map ⇒ Object
readonly
A hash with class name symbol keys and table name symbol values.
-
#cti_tables ⇒ Object
readonly
An array of table symbols that back this model.
Instance Method Summary collapse
-
#cti_table_name ⇒ Object
The name of the most recently joined table.
-
#freeze ⇒ Object
Freeze CTI information when freezing model class.
-
#sti_class_from_key(key) ⇒ Object
The model class for the given key value.
-
#table_name ⇒ Object
The table name for the current model class’s main table.
Instance Attribute Details
#cti_ignore_subclass_columns ⇒ Object (readonly)
An array of columns that may be duplicated in sub-classes. The primary key column is always allowed to be duplicated
259 260 261 |
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 259 def cti_ignore_subclass_columns @cti_ignore_subclass_columns end |
#cti_instance_dataset ⇒ Object (readonly)
The dataset that table instance datasets are based on. Used for database modifications
245 246 247 |
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 245 def cti_instance_dataset @cti_instance_dataset end |
#cti_models ⇒ Object (readonly)
An array of each model in the inheritance hierarchy that is backed by a new table.
237 238 239 |
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 237 def cti_models @cti_models end |
#cti_qualify_tables ⇒ Object (readonly)
A boolean indicating whether or not to automatically qualify tables backing subclasses with the same qualifier as their superclass, if the superclass is qualified. Specified with the :qualify_tables option to the plugin and only applied to automatically determined table names (not to the :table_map option).
266 267 268 |
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 266 def cti_qualify_tables @cti_qualify_tables end |
#cti_table_columns ⇒ Object (readonly)
An array of column symbols for the backing database table, giving the columns to update in each backing database table.
241 242 243 |
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 241 def cti_table_columns @cti_table_columns end |
#cti_table_map ⇒ Object (readonly)
A hash with class name symbol keys and table name symbol values. Specified with the :table_map option to the plugin, and should be used if the implicit naming is incorrect.
255 256 257 |
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 255 def cti_table_map @cti_table_map end |
#cti_tables ⇒ Object (readonly)
An array of table symbols that back this model. The first is table symbol for the base model, and the last is the current model table symbol.
250 251 252 |
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 250 def cti_tables @cti_tables end |
Instance Method Details
#cti_table_name ⇒ Object
The name of the most recently joined table.
291 292 293 |
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 291 def cti_table_name cti_tables.last end |
#freeze ⇒ Object
Freeze CTI information when freezing model class.
269 270 271 272 273 274 275 276 277 |
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 269 def freeze @cti_models.freeze @cti_tables.freeze @cti_table_columns.freeze @cti_table_map.freeze @cti_ignore_subclass_columns.freeze super end |
#sti_class_from_key(key) ⇒ Object
The model class for the given key value.
296 297 298 |
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 296 def sti_class_from_key(key) sti_class(sti_model_map[key]) end |
#table_name ⇒ Object
The table name for the current model class’s main table.
282 283 284 285 286 287 288 |
# File 'lib/sequel/plugins/class_table_inheritance.rb', line 282 def table_name if cti_tables && cti_tables.length > 1 @cti_alias else super end end |