Class: QTimetrap::Services::ArchivedEntriesStore
- Inherits:
-
Object
- Object
- QTimetrap::Services::ArchivedEntriesStore
- Defined in:
- app/services/archived_entries_store.rb
Overview
Persists archived Timetrap entry ids in a local app-owned store.
Instance Method Summary collapse
- #archive(entry_id) ⇒ Object
- #archived?(entry_id) ⇒ Boolean
- #archived_ids ⇒ Object
-
#initialize(path: default_path) ⇒ ArchivedEntriesStore
constructor
A new instance of ArchivedEntriesStore.
- #unarchive(entry_id) ⇒ Object
Constructor Details
#initialize(path: default_path) ⇒ ArchivedEntriesStore
Returns a new instance of ArchivedEntriesStore.
10 11 12 |
# File 'app/services/archived_entries_store.rb', line 10 def initialize(path: default_path) @path = path end |
Instance Method Details
#archive(entry_id) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/archived_entries_store.rb', line 24 def archive(entry_id) id = Integer(entry_id) ids = read_ids return if ids.include?(id) ids << id write_ids(ids) rescue ArgumentError, TypeError nil end |
#archived?(entry_id) ⇒ Boolean
18 19 20 21 22 |
# File 'app/services/archived_entries_store.rb', line 18 def archived?(entry_id) read_ids.include?(Integer(entry_id)) rescue ArgumentError, TypeError false end |
#archived_ids ⇒ Object
14 15 16 |
# File 'app/services/archived_entries_store.rb', line 14 def archived_ids read_ids end |
#unarchive(entry_id) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'app/services/archived_entries_store.rb', line 35 def unarchive(entry_id) id = Integer(entry_id) ids = read_ids return unless ids.delete(id) write_ids(ids) rescue ArgumentError, TypeError nil end |