Created
June 5, 2025 08:48
-
-
Save alexcastrodev/6a7f4fd069eacfb622014b51c5707038 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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