-
-
Save rsl/9f1e652a8199376c1859 to your computer and use it in GitHub Desktop.
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
module Foo | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
module ClassMethods | |
def desideratum | |
"yup" | |
end | |
end | |
end | |
module Bar | |
include Foo | |
end | |
puts Bar.desideratum # => "yup" | |
class Baz | |
include Bar | |
end | |
puts Baz.desideratum # => undefined method `desideratum' for Baz:Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, this approach is not recommended anymore for exactly this reason. Instead, to include concerns the recommended approach is to use
ActiveSupport::Concern
. See fx Yehuda Katz' article about this.