Skip to content

Instantly share code, notes, and snippets.

@okuramasafumi
Created April 17, 2023 13:27
Show Gist options
  • Save okuramasafumi/d283c6d06b63a7f96ad69908780b19bd to your computer and use it in GitHub Desktop.
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
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