module PowerStencil module Plugins module EntityDefinitions def require_plugin_entity_definitions return unless capabilities[:entity_definitions] logger.info "Requiring '#{self.name}' plugin entity definitions..." securely_require_with_entity_class_detection end private def securely_require_with_entity_class_detection before = PowerStencil::Engine::EntitiesHandling.all_types plugin_definition[:entity_definitions].each do |entity_definition_file_path| securely_require entity_definition_file_path, fail_on_error: true end after = PowerStencil::Engine::EntitiesHandling.all_types after.reject { |k, _| before.keys.include? k }.each do |_, plugin_entity_class| plugin = self plugin_entity_class.instance_eval do @entity_type_source_provider = plugin end end end end end end