Module: Shared::IsData::Scopes::ClassMethods

Defined in:
app/models/concerns/shared/is_data/scopes.rb

Instance Method Summary collapse

Instance Method Details

#not_ids(*ids) ⇒ Scope

! Not built for collisions

Returns:

  • (Scope)


20
21
22
# File 'app/models/concerns/shared/is_data/scopes.rb', line 20

def not_ids(*ids)
  where.not(id: ids)
end

#not_self(object) ⇒ Scope

a where clause that excludes the present object from being selected

Returns:

  • (Scope)


8
9
10
11
12
13
14
# File 'app/models/concerns/shared/is_data/scopes.rb', line 8

def not_self(object)
  if object.nil? || object.id.blank?
    where(object.class.table_name => {id: '<> 0'})
  else
    where(object.class.arel_table[:id].not_eq(object.to_param))
  end
end