require 'olivander/resources/model_registry' module Olivander module Resources module ModelRegistrar extend ActiveSupport::Concern included do def this_is_included_method puts 'hi' end end class_methods do def register_model(model = self, context: :default, using: self, &block) Rails.logger.debug "###################" Rails.logger.debug "registering model #{model.name} in context #{context} using #{using&.name} at #{self.name}" using.register_model(model, context: context, &block) && return unless using == self ::Olivander::Resources::ModelRegistry.global_registry.register(model, &block) Rails.logger.debug "###################\n" end end end class TestRegistrant end class TestRegistrar include ModelRegistrar end class TestRegistrar2 include ModelRegistrar # register_model do # puts 'hello' # field_layout :show do :all end # end # register_model Olivander::Resources::TestRegistrant, context: :foo do # puts 'this is the other thing' # field_layout do [[1, :id]] end # end # register_model context: :bar, using: TestRegistrar do # puts 'and lastly...' # end end end end