Module: StorageUnit::Core::ClassMethods

Defined in:
lib/storage_unit/core.rb

Instance Method Summary collapse

Instance Method Details

#deleted_onlyObject



28
29
30
# File 'lib/storage_unit/core.rb', line 28

def deleted_only
  with_deleted.where(deleted_only_scope_sql)
end

#deleted_only_scope_sqlObject



16
17
18
# File 'lib/storage_unit/core.rb', line 16

def deleted_only_scope_sql
  all.table[storage_unit_opts[:column]].not_eq(nil).to_sql
end

#with_deletedObject

lifted from acts_as_paranoid, works around github.com/rails/rails/issues/4306 with this in place Post.limit(10).with_deleted, will work as expected



22
23
24
25
26
# File 'lib/storage_unit/core.rb', line 22

def with_deleted
  scope = self.all
  scope.where_values.delete(with_deleted_scope_sql)
  scope
end

#with_deleted_scope_sqlObject



12
13
14
# File 'lib/storage_unit/core.rb', line 12

def with_deleted_scope_sql
  all.table[storage_unit_opts[:column]].eq(nil).to_sql
end