Sha256: 76af6d0b59c3e092aeef86dda4024fa5e51e7e3ea665cf166788a6d7c6066313

Contents?: true

Size: 1.45 KB

Versions: 26

Compression:

Stored size: 1.45 KB

Contents

module Foobara
  module Persistence
    class EntityBase
      class TransactionTable
        module Concerns
          # If something accesses the crud driver and manipulates records then it belongs in this concern.
          module Queries
            # TODO: why is this query method here but the rest are not?
            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
          end
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
foobara-0.0.26 projects/persistence/src/entity_base/transaction_table/concerns/queries.rb
foobara-0.0.25 projects/persistence/src/entity_base/transaction_table/concerns/queries.rb
foobara-0.0.24 projects/persistence/src/entity_base/transaction_table/concerns/queries.rb
foobara-0.0.23 projects/persistence/src/entity_base/transaction_table/concerns/queries.rb
foobara-0.0.22 projects/persistence/src/entity_base/transaction_table/concerns/queries.rb
foobara-0.0.21 projects/persistence/src/entity_base/transaction_table/concerns/queries.rb
foobara-0.0.20 projects/persistence/src/entity_base/transaction_table/concerns/queries.rb
foobara-0.0.19 projects/persistence/src/entity_base/transaction_table/concerns/queries.rb
foobara-0.0.18 projects/persistence/src/entity_base/transaction_table/concerns/queries.rb
foobara-0.0.17 projects/persistence/src/entity_base/transaction_table/concerns/queries.rb
foobara-0.0.16 projects/persistence/src/entity_base/transaction_table/concerns/queries.rb
foobara-0.0.15 projects/persistence/src/entity_base/transaction_table/concerns/queries.rb
foobara-0.0.14 projects/persistence/src/entity_base/transaction_table/concerns/queries.rb
foobara-0.0.13 projects/persistence/src/entity_base/transaction_table/concerns/queries.rb
foobara-0.0.12 projects/persistence/src/entity_base/transaction_table/concerns/queries.rb
foobara-0.0.11 projects/persistence/src/entity_base/transaction_table/concerns/queries.rb
foobara-0.0.10 projects/persistence/src/entity_base/transaction_table/concerns/queries.rb
foobara-0.0.9 projects/persistence/src/entity_base/transaction_table/concerns/queries.rb
foobara-0.0.8 projects/persistence/src/entity_base/transaction_table/concerns/queries.rb
foobara-0.0.7 projects/persistence/src/entity_base/transaction_table/concerns/queries.rb