From e3bb7b826d76bc9c5b714dd6c875309a64458732 Mon Sep 17 00:00:00 2001 From: f Date: Sat, 3 Oct 2020 22:31:37 -0300 Subject: [PATCH] =?UTF-8?q?cach=C3=A9=20de=20la=20f=C3=A1brica=20de=20meta?= =?UTF-8?q?datos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/metadata_factory.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/metadata_factory.rb b/app/models/metadata_factory.rb index d7a2e039..8cac1c86 100644 --- a/app/models/metadata_factory.rb +++ b/app/models/metadata_factory.rb @@ -3,6 +3,8 @@ # Devuelve metadatos de cierto tipo class MetadataFactory def self.build(**args) - "Metadata#{args[:type].camelcase}".constantize.new(args) + @@factory_cache ||= {} + @@factory_cache[args[:type]] ||= ('Metadata' + args[:type].to_s.camelcase).constantize + @@factory_cache[args[:type]].new(args) end end