Module: Disallow::Scopes

Included in:
Model::ClassMethods
Defined in:
lib/disallow/scopes.rb

Instance Method Summary collapse

Instance Method Details

#default_scope(*args) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/disallow/scopes.rb', line 13

def default_scope(*args)
  if @disallow_default_scope
    raise Disallow::DefaultScopeError.new(name)
  end

  super(*args)
end

#disallow_default_scope!(options = {}) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/disallow/scopes.rb', line 5

def disallow_default_scope!(options = {})
  if default_scopes.present?
    raise Disallow::DefaultScopeError.new(name)
  end

  @disallow_default_scope = true
end