Overriding class_attribute writers and order of super/extend C.M./included block eval in ActiveSupport::Concern

I have:

module MySpike
extend ActiveSupport::Concern included do class_attribute :foobar, instance_writer: true end end

But, I want to be able to override the class attribute writer and/or instance writer method to do something when the attribute is set via self.foobar = true before or after calling super to set the attribute.

Unfortunately, I can’t find a clean way of doing this, and it is a little confusing when the order of things is typically to put included at the top even though it isn’t evaluated before ClassMethods is extended, etc.

I’m not sure if it would help, but would be nice if the order of the following that happen in Concern’s def append_features(base) method were different and maybe then I could just override things in the ClassMethods module for class methods and the main block of the module for instance methods:

    super
    base.extend const_get("ClassMethods") if const_defined?("ClassMethods")
    base.class_eval(&@_included_block) if instance_variable_defined?("@_included_block")

And there are classes like this that only benefit from the dependency handling and included block class_eval part of Concern that maybe could benefit from that being split up somehow?:

actionpack/lib/abstract_controller/asset_paths.rb:

module AbstractController module AssetPaths #:nodoc: extend ActiveSupport::Concern

included do
  config_accessor :asset_host, :asset_path, :assets_dir, :javascripts_dir,
    :stylesheets_dir, :default_asset_host_protocol, :relative_url_root
end

end end

Sorry if this is an uninformed way of looking at it. I guess if it was problematic it would have been solved already. Thanks for listening though.