Skip to content

Instantly share code, notes, and snippets.

@niaeashes
Created April 12, 2017 03:41
Show Gist options
  • Save niaeashes/895e933718001c400ce6280533d0b53d to your computer and use it in GitHub Desktop.
Save niaeashes/895e933718001c400ce6280533d0b53d to your computer and use it in GitHub Desktop.
require 'active_support'
module A
extend ::ActiveSupport::Concern
class_methods do
def sample=value
@sample = value
end
def sample
@sample
end
end
end
class B
include A
end
class C
include A
end
B.sample = "ok"
C.sample = "ng"
puts B.sample
puts C.sample
# > ok
# > ng
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment