Class: Pageflow::FileFolder Private
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Pageflow::FileFolder
- Includes:
- RevisionComponent
- Defined in:
- app/models/pageflow/file_folder.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.
Groups the file usages of a revision. Folders refer to their parent folder by perma id since row ids would not survive copying a revision.
Instance Method Summary collapse
-
#ancestors ⇒ Object
private
Broken data with a folder nested inside one of its own descendants would make walking up the tree loop forever.
- #children ⇒ Object private
- #empty? ⇒ Boolean private
- #file_usages ⇒ Object private
- #parent ⇒ Object private
Methods included from RevisionComponent
#entry_for_auto_generated_perma_id
Methods included from AutoGeneratedPermaId
#ensure_perma_id, #entry_for_auto_generated_perma_id
Instance Method Details
#ancestors ⇒ 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.
Broken data with a folder nested inside one of its own descendants would make walking up the tree loop forever.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/models/pageflow/file_folder.rb', line 22 def ancestors result = [] current = parent while current && result.exclude?(current) result.unshift(current) current = current.parent end result end |
#children ⇒ 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.
34 35 36 |
# File 'app/models/pageflow/file_folder.rb', line 34 def children folders_of_revision.where(parent_folder_perma_id: perma_id) end |
#empty? ⇒ Boolean
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.
42 43 44 |
# File 'app/models/pageflow/file_folder.rb', line 42 def empty? children.none? && file_usages.none? end |
#file_usages ⇒ 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.
38 39 40 |
# File 'app/models/pageflow/file_folder.rb', line 38 def file_usages revision.file_usages.where(folder_perma_id: perma_id) end |
#parent ⇒ 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.
14 15 16 17 18 |
# File 'app/models/pageflow/file_folder.rb', line 14 def parent return if parent_folder_perma_id.blank? folders_of_revision.find_by(perma_id: parent_folder_perma_id) end |