Skip to content

Instantly share code, notes, and snippets.

@danimal141
Created March 15, 2014 09:30
Show Gist options
  • Save danimal141/9564002 to your computer and use it in GitHub Desktop.
Save danimal141/9564002 to your computer and use it in GitHub Desktop.
ClassMethods test 2
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