Created
April 17, 2023 13:27
-
-
Save okuramasafumi/d283c6d06b63a7f96ad69908780b19bd to your computer and use it in GitHub Desktop.
Tell me if this module is included by the same class more than once
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
def self.included(base) | |
base.instance_variable_set(:@count, 0) unless base.instance_variable_defined?(:@count) | |
base.instance_variable_set(:@count, base.instance_variable_get(:@count) + 1) | |
puts base.name if base.instance_variable_get(:@count) > 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment