Access a variable in Railtie initializer from other class

85 Views Asked by At

I have a gem which has the following Railtie class. I am trying to access my_config variable from outside, i.e another ruby class in the same gem. How can I access it?

module myModule
    module Rails
      class Railtie < ::Rails::Railtie

        initializer 'load_config' do
          my_config = "random config here"
          puts my_config
        end
      end
    end
  end
end
1

There are 1 best solutions below

0
Thanh On

Maybe you can use instance_variable_get:

myModule::Rails::Railtie.new.instance_variable_get(:@my_config)