Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

store class names instead of classes in acts_as_ registries

Ivan Kuchin4b37ca85e60a
diff --git a/lib_static/open_project/acts/registry_methods.rb b/lib_static/open_project/acts/registry_methods.rb
index 2e7ffabd2c3..ff0f275d370 100644
--- a/lib_static/open_project/acts/registry_methods.rb
+++ b/lib_static/open_project/acts/registry_methods.rb
@@ -30,7 +30,9 @@ module OpenProject
module Acts
module RegistryMethods
def instance(model_name)
- models.detect { |cls| cls.name == model_name.singularize.camelize }
+ class_name = model_name.singularize.camelize
+
+ class_name.constantize if class_names.include?(class_name)
end
def add(*models)
@@ -42,14 +44,14 @@ module OpenProject
raise ArgumentError.new("Model #{model} does not include #{acts_as_method_name}")
end
- self.models << model
+ class_names << model.name
end
end
private
- def models
- @models ||= Set.new
+ def class_names
+ @class_names ||= Set.new
end
end
end