Class: Infold::ModelColumn
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Infold::ModelColumn
- Defined in:
- app/models/infold/model_column.rb
Instance Method Summary collapse
- #has_detail_setting? ⇒ Boolean
- #is_foreign_key? ⇒ Boolean
- #is_primary_key? ⇒ Boolean
- #is_timestamp_field? ⇒ Boolean
- #locale_or_name ⇒ Object
- #locale_or_name_with_foreign_key ⇒ Object
- #name_with_foreign_key ⇒ Object
- #not_null? ⇒ Boolean
- #required_validate? ⇒ Boolean
- #unique? ⇒ Boolean
- #view_form_default_display? ⇒ Boolean
Instance Method Details
#has_detail_setting? ⇒ Boolean
95 96 97 |
# File 'app/models/infold/model_column.rb', line 95 def has_detail_setting? !%w(date datetime boolean).include?(kind) end |
#is_foreign_key? ⇒ Boolean
50 51 52 |
# File 'app/models/infold/model_column.rb', line 50 def is_foreign_key? kind_reference? end |
#is_primary_key? ⇒ Boolean
54 55 56 |
# File 'app/models/infold/model_column.rb', line 54 def is_primary_key? model.pk_column == self end |
#is_timestamp_field? ⇒ Boolean
58 59 60 |
# File 'app/models/infold/model_column.rb', line 58 def self == model. || self == model. end |
#locale_or_name ⇒ Object
91 92 93 |
# File 'app/models/infold/model_column.rb', line 91 def locale_or_name locale.presence || name end |
#locale_or_name_with_foreign_key ⇒ Object
62 63 64 |
# File 'app/models/infold/model_column.rb', line 62 def locale_or_name_with_foreign_key model_association&.locale.presence || locale_or_name end |
#name_with_foreign_key ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'app/models/infold/model_column.rb', line 66 def name_with_foreign_key if is_foreign_key? association_label_name = model_association.parent_model.label_column&.name "#{name} (#{model_association.belongs_name}.#{association_label_name || 'id'})" else name end end |
#not_null? ⇒ Boolean
75 76 77 |
# File 'app/models/infold/model_column.rb', line 75 def not_null? not_null_app? || not_null_db? end |
#required_validate? ⇒ Boolean
79 80 81 |
# File 'app/models/infold/model_column.rb', line 79 def required_validate? not_null? && !kind_boolean? && !is_primary_key? && ! end |
#unique? ⇒ Boolean
83 84 85 |
# File 'app/models/infold/model_column.rb', line 83 def unique? unique_app? || unique_db? end |
#view_form_default_display? ⇒ Boolean
87 88 89 |
# File 'app/models/infold/model_column.rb', line 87 def view_form_default_display? !is_primary_key? && self != model. && self != model. end |