Class: ActiveProjection::ProjectionRepository
- Inherits:
-
Object
- Object
- ActiveProjection::ProjectionRepository
- Defined in:
- app/models/active_projection/projection_repository.rb
Class Method Summary collapse
- .create_or_get(projection_class) ⇒ 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
.create_or_get(projection_class) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'app/models/active_projection/projection_repository.rb', line 26 def self.create_or_get(projection_class) projection = Projection.where(class_name: projection_class).first if projection.nil? projection = Projection.create! class_name: projection_class, last_id: 0, solid: true else projection.update! solid: true end projection end |
.get_last_id(id) ⇒ Object
8 9 10 |
# File 'app/models/active_projection/projection_repository.rb', line 8 def self.get_last_id(id) @@last_id[id] ||= Projection.find(id).last_id end |
.last_ids ⇒ Object
4 5 6 |
# File 'app/models/active_projection/projection_repository.rb', line 4 def self.last_ids Projection.all.to_a.map { |p| p.last_id } end |
.set_broken(id) ⇒ Object
17 18 19 20 |
# File 'app/models/active_projection/projection_repository.rb', line 17 def self.set_broken(id) @@broken[id] = false Projection.find(id).update! solid: false end |
.set_last_id(id, last_id) ⇒ Object
12 13 14 15 |
# File 'app/models/active_projection/projection_repository.rb', line 12 def self.set_last_id(id, last_id) Projection.find(id).update! last_id: last_id @@last_id[id] += 1 end |
.solid?(id) ⇒ Boolean
22 23 24 |
# File 'app/models/active_projection/projection_repository.rb', line 22 def self.solid?(id) @@broken[id] ||= Projection.find(id).solid end |