diff --git a/app/models/metadata_factory.rb b/app/models/metadata_factory.rb index 8cac1c86..c33f1f18 100644 --- a/app/models/metadata_factory.rb +++ b/app/models/metadata_factory.rb @@ -2,9 +2,14 @@ # Devuelve metadatos de cierto tipo class MetadataFactory - def self.build(**args) - @@factory_cache ||= {} - @@factory_cache[args[:type]] ||= ('Metadata' + args[:type].to_s.camelcase).constantize - @@factory_cache[args[:type]].new(args) + class << self + def build(**args) + classify(args[:type]).new(**args) + end + + def classify(type) + @factory_cache ||= {} + @factory_cache[type] ||= ('Metadata' + type.to_s.camelcase).constantize + end end end