Module: Foobara::Persistence::EntityBase::TransactionTable::Concerns::Queries
- Defined in:
- foobara-0.0.110/projects/persistence/src/entity_base/transaction_table/concerns/queries.rb
Overview
If something accesses the crud driver and manipulates records then it belongs in this concern.
Instance Method Summary collapse
-
#all ⇒ Object
TODO: why is this query method here but the rest are not?.
Instance Method Details
#all ⇒ Object
TODO: why is this query method here but the rest are not?
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'foobara-0.0.110/projects/persistence/src/entity_base/transaction_table/concerns/queries.rb', line 9 def all(&) enumerator = Enumerator.new do |yielder| tracked_records.each do |record| next if record.hard_deleted? # if the record is not loaded, it could be an unloaded thunk with a primary key to a row that has # been deleted or maybe never even existed. So just exclude those and let them come from the # database in the next loop if created?(record) || record.loaded? yielder << record end end entity_attributes_crud_driver_table.all.each do |attributes| attributes = normalize_attributes(attributes) primary_key = primary_key_for_attributes(attributes) next if tracked_records.include_key?(primary_key) yielder << entity_class.loaded(attributes) end end if block_given? enumerator.each(&) else enumerator.to_a end end |