Here is a runnable test to see the situation
require 'active_support'
module MyModule
extend ActiveSupport::Concern
included do
cattr_accessor :value
end
end
class A
include MyModule
self.value = 'a'
end
class B < A
self.value = 'b'
end
class C < A
self.value = 'c'
end
puts A.value
puts B.value
puts C.value
the output is:
$ ruby test.rb
c
c
c
Now, I'd think the output should be
a
b
c
but it's all just whatever was set last.
If I move the include to class B and C and have class A not include the module, then I get the desired output... but then I have includes everywhere... so I feel like this is an issue with my cattr_accessor usage?
Why is this, and how do I achieve the desired functionality?