Module: RailsAdmin::Config::ConstLoadSuppressor

Included in:
RailsAdmin
Defined in:
lib/rails_admin/config/const_load_suppressor.rb

Defined Under Namespace

Classes: ConstProxy

Class Method Summary collapse

Class Method Details

.allowingObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rails_admin/config/const_load_suppressor.rb', line 22

def allowing
  if @original_const_missing
    begin
      Object.define_singleton_method(:const_missing, @original_const_missing)
      yield
    ensure
      intercept_const_missing
    end
  else
    yield
  end
end

.suppressingObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rails_admin/config/const_load_suppressor.rb', line 9

def suppressing
  raise 'Constant Loading is already suppressed' if @original_const_missing

  begin
    @original_const_missing = Object.method(:const_missing)
    intercept_const_missing
    yield
  ensure
    Object.define_singleton_method(:const_missing, @original_const_missing)
    @original_const_missing = nil
  end
end