Created
March 15, 2014 09:30
-
-
Save danimal141/9564002 to your computer and use it in GitHub Desktop.
ClassMethods test 2
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
require 'active_support/concern' | |
module M1 | |
# ActiveSupport::Concernをextendしとけばdef included(klass)~とかしなくても勝手にClassMethods取り込んでくれる | |
# ActiveSupport::Concernがincludeで呼び出されるappend_featuresを上書きしてるぽい | |
extend ActiveSupport::Concern | |
def method_i | |
p 'InstanceMethodですよー' | |
end | |
module ClassMethods | |
def method_c | |
p 'ClassMethodsからきましたよー' | |
end | |
end | |
end | |
class C1 | |
include M1 | |
end | |
C1.method_c | |
C1.new.method_i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment