Skip to content

Instantly share code, notes, and snippets.

@alexcastrodev
Created June 5, 2025 08:48
Show Gist options
  • Save alexcastrodev/6a7f4fd069eacfb622014b51c5707038 to your computer and use it in GitHub Desktop.
Save alexcastrodev/6a7f4fd069eacfb622014b51c5707038 to your computer and use it in GitHub Desktop.
module MyLib
class MyClass
class << self
attr_accessor :api_key
end
def self.my_method
puts "key: #{api_key}"
end
end
end
module MyService
class ModuleA
def self.get_my_method
MyLib::MyClass.my_method
end
end
class ModuleGeneric
def initialize
MyLib::MyClass.api_key = "super-secret"
@module = ModuleA
end
def get_my_method
@module.get_my_method
end
end
end
s = MyService::ModuleGeneric.new
s.get_my_method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment