Class: Nexo::Folder
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- ApplicationRecord
- Nexo::Folder
- Defined in:
- app/models/nexo/folder.rb
Instance Method Summary collapse
- #discard! ⇒ Object
- #discarded? ⇒ Boolean
-
#find_element(synchronizable:) ⇒ Object
TODO: use find_sole_by.
- #policy_applies?(synchronizable) ⇒ Boolean
- #sync_external_changes? ⇒ Boolean
- #sync_internal_changes? ⇒ Boolean
- #time_zone ⇒ Object
- #to_s ⇒ Object
Instance Method Details
#discard! ⇒ Object
62 63 64 |
# File 'app/models/nexo/folder.rb', line 62 def discard! update!(discarded_at: Time.current) end |
#discarded? ⇒ Boolean
58 59 60 |
# File 'app/models/nexo/folder.rb', line 58 def discarded? discarded_at.present? end |
#find_element(synchronizable:) ⇒ Object
TODO: use find_sole_by
44 45 46 47 48 49 50 51 52 |
# File 'app/models/nexo/folder.rb', line 44 def find_element(synchronizable:) ary = elements.where(synchronizable:, discarded_at: nil).to_a if ary.count > 1 raise Errors::MoreThanOneElementInFolderForSynchronizable end ary.first end |
#policy_applies?(synchronizable) ⇒ Boolean
39 40 41 |
# File 'app/models/nexo/folder.rb', line 39 def policy_applies?(synchronizable) PolicyService.instance.applies?(self, synchronizable) end |
#sync_external_changes? ⇒ Boolean
27 28 29 |
# File 'app/models/nexo/folder.rb', line 27 def sync_external_changes? sync_out_in? || sync_bidirectional? end |
#sync_internal_changes? ⇒ Boolean
31 32 33 |
# File 'app/models/nexo/folder.rb', line 31 def sync_internal_changes? sync_in_out? || sync_bidirectional? end |
#time_zone ⇒ Object
54 55 56 |
# File 'app/models/nexo/folder.rb', line 54 def time_zone Rails.application.config.time_zone end |
#to_s ⇒ Object
66 67 68 |
# File 'app/models/nexo/folder.rb', line 66 def to_s name.presence || super end |