Class: ActiveProjection::ProjectionRepository
- Inherits:
-
Object
- Object
- ActiveProjection::ProjectionRepository
- Defined in:
- app/models/active_projection/projection_repository.rb
Class Method Summary collapse
- .ensure_exists(projection_class) ⇒ Object
- .ensure_solid(projection_class) ⇒ Object
- .get_all_broken ⇒ Object
- .get_last_id(id) ⇒ Object
- .last_ids ⇒ Object
- .set_broken(id) ⇒ Object
- .set_last_id(id, last_id) ⇒ Object
- .solid?(id) ⇒ Boolean
Class Method Details
.ensure_exists(projection_class) ⇒ Object
27 28 29 30 31 |
# File 'app/models/active_projection/projection_repository.rb', line 27 def self.ensure_exists(projection_class) Projection.transaction do Projection.find_or_create_by! class_name: projection_class end end |
.ensure_solid(projection_class) ⇒ Object
33 34 35 36 37 38 |
# File 'app/models/active_projection/projection_repository.rb', line 33 def self.ensure_solid(projection_class) Projection.transaction do projection = Projection.find_or_initialize_by class_name: projection_class projection.update! solid: true end end |
.get_all_broken ⇒ Object
19 20 21 |
# File 'app/models/active_projection/projection_repository.rb', line 19 def self.get_all_broken Projection.where(solid: false).to_a.map { |p| p.class_name } end |
.get_last_id(id) ⇒ Object
7 8 9 |
# File 'app/models/active_projection/projection_repository.rb', line 7 def self.get_last_id(id) Projection.find(id).last_id end |
.last_ids ⇒ Object
3 4 5 |
# File 'app/models/active_projection/projection_repository.rb', line 3 def self.last_ids Projection.all.to_a.map { |p| p.last_id } end |
.set_broken(id) ⇒ Object
15 16 17 |
# File 'app/models/active_projection/projection_repository.rb', line 15 def self.set_broken(id) Projection.find(id).update! solid: false end |
.set_last_id(id, last_id) ⇒ Object
11 12 13 |
# File 'app/models/active_projection/projection_repository.rb', line 11 def self.set_last_id(id, last_id) Projection.find(id).update! last_id: last_id end |
.solid?(id) ⇒ Boolean
23 24 25 |
# File 'app/models/active_projection/projection_repository.rb', line 23 def self.solid?(id) Projection.find(id).solid end |