I'm making a concern, but I want to limit what the Class that is getting it can see. For example, I don't want anyone to use PRIVATE_FOO
or PRIVATE_BAR
separately, I just want them to use them together in PUBLIC_FOOBAR
. Is this possible?
module MyConcern
extend ActiveSupport::Concern
##This should not be visible in the class it is included in:
PRIVATE_FOO = 'foo'
PRIVATE_BAR = 'bar'
##This should be visible to the class it is included in:
PUBLIC_FOOBAR = PRIVATE_FOO + PRIVATE_BAR
end
class MyClass < ApplicationRecord
include MyConcern
PRIVATE_FOO # NameError Exception
PRIVATE_BAR # NameError Exception
PUBLIC_FOOBAR # "foobar"
end