Class: RailsAdmin::Config::ConstLoadSuppressor::ConstProxy

Inherits:
BasicObject
Defined in:
lib/rails_admin/config/const_load_suppressor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ ConstProxy

Returns a new instance of ConstProxy.



47
48
49
# File 'lib/rails_admin/config/const_load_suppressor.rb', line 47

def initialize(name)
  @name = name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



68
69
70
# File 'lib/rails_admin/config/const_load_suppressor.rb', line 68

def method_missing(method_name, *args, &block)
  klass.send(method_name, *args, &block)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



45
46
47
# File 'lib/rails_admin/config/const_load_suppressor.rb', line 45

def name
  @name
end

Instance Method Details

#klassObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/rails_admin/config/const_load_suppressor.rb', line 51

def klass
  @klass ||=
    begin
      unless ::Object.const_defined?(name)
        ::Kernel.raise <<~MESSAGE
          The constant #{name} is not loaded yet upon the execution of the RailsAdmin initializer.
          We don't recommend to do this and may lead to issues, but if you really have to do so you can explicitly require it by adding:

            require '#{name.underscore}'

          on top of config/initializers/rails_admin.rb.
        MESSAGE
      end
      name.constantize
    end
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/rails_admin/config/const_load_suppressor.rb', line 72

def respond_to_missing?(method_name, include_private = false)
  super || klass.respond_to?(method_name, include_private)
end