-
-
Save paneq/2241f6c8aa9a0a12e2ce to your computer and use it in GitHub Desktop.
constants problem asked in http://blog.arkency.com/2014/11/dont-forget-about-eager-load-when-extending-autoload/#comment-1782745182
This file contains 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
# keep in one file | |
class Whatever | |
class A | |
def self.interface_method | |
end | |
end | |
class B | |
def self.interface_method | |
end | |
end | |
def something | |
end | |
end |
This file contains 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
class Whatever | |
def something | |
end | |
end | |
# force loading by using class names | |
Whatever::A | |
Whatever::B |
This file contains 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
class Whatever | |
def something | |
end | |
end | |
# force loading by requiring files (in a way compatibile with rails dependency tracking) | |
require_dependency 'whatever/a' | |
require_dependency 'whatever/b' |
This file contains 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
class Whatever | |
def something | |
end | |
def self.constants | |
# force loading by requiring files but only when someone needs it | |
require_dependency 'whatever/a' | |
require_dependency 'whatever/b' | |
super | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment