Class: Taxon
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Taxon
- Includes:
- Checkable, HasSimpleImage, HasUuid, NestedPriority, Toggleable, TreeStructure
- Defined in:
- app/models/taxon.rb
Overview
Taxon
Attributes:
children_cache [Array<integer>]
created_at [DateTime]
data [jsonb]
name [string]
nav_text [string]
object_count [integer]
parent_id [integer], optional
parents_cache [string]
priority [integer]
simple_image_id [SimpleImage], optional
slug [string]
updated_at [DateTime]
uuid [uuid]
visible [boolean]
Constant Summary collapse
- SLUG_LIMIT =
50
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.creation_parameters ⇒ Object
51 52 53 |
# File 'app/models/taxon.rb', line 51 def self.creation_parameters entity_parameters + %i[parent_id] end |
.entity_parameters ⇒ Object
47 48 49 |
# File 'app/models/taxon.rb', line 47 def self.entity_parameters %i[name nav_text priority simple_image_id slug visible] end |
.siblings(entity) ⇒ Object
43 44 45 |
# File 'app/models/taxon.rb', line 43 def self.siblings(entity) where(parent_id: entity&.parent_id) end |
Instance Method Details
#long_name ⇒ Object
59 60 61 |
# File 'app/models/taxon.rb', line 59 def long_name (parents.map(&:name) + [text_for_link]).join('/') end |
#text_for_link ⇒ Object
55 56 57 |
# File 'app/models/taxon.rb', line 55 def text_for_link nav_text.blank? ? name : nav_text end |