Class: Tartarus::ArchivableCollectionRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/tartarus/archivable_collection_repository.rb

Instance Method Summary collapse

Constructor Details

#initialize(const_resolver: Object) ⇒ ArchivableCollectionRepository

Returns a new instance of ArchivableCollectionRepository.



6
7
8
# File 'lib/tartarus/archivable_collection_repository.rb', line 6

def initialize(const_resolver: Object)
  @const_resolver = const_resolver
end

Instance Method Details

#items_older_than(model_name, timestamp_field, timestamp) ⇒ Object



18
19
20
21
22
23
# File 'lib/tartarus/archivable_collection_repository.rb', line 18

def items_older_than(model_name, timestamp_field, timestamp)
  collection = collection_for(model_name)
  ensure_column_exists(collection, model_name, timestamp_field)

  collection.where("#{timestamp_field} < ?", timestamp)
end

#items_older_than_for_tenant(model_name, timestamp_field, timestamp, tenant_id_field, tenant_id) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/tartarus/archivable_collection_repository.rb', line 10

def items_older_than_for_tenant(model_name, timestamp_field, timestamp, tenant_id_field, tenant_id)
  collection = collection_for(model_name)
  ensure_column_exists(collection, model_name, timestamp_field)
  ensure_column_exists(collection, model_name, tenant_id_field)

  collection.where("#{timestamp_field} < ?", timestamp).where(tenant_id_field => tenant_id)
end