5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-25 13:46:22 +00:00

preparar MetadataFactory para poder llamar métodos estáticos

This commit is contained in:
f 2021-02-17 18:41:42 -03:00
parent aa66e2cc9b
commit 0c6b85c030

View file

@ -2,9 +2,14 @@
# Devuelve metadatos de cierto tipo # Devuelve metadatos de cierto tipo
class MetadataFactory class MetadataFactory
def self.build(**args) class << self
@@factory_cache ||= {} def build(**args)
@@factory_cache[args[:type]] ||= ('Metadata' + args[:type].to_s.camelcase).constantize classify(args[:type]).new(**args)
@@factory_cache[args[:type]].new(args) end
def classify(type)
@factory_cache ||= {}
@factory_cache[type] ||= ('Metadata' + type.to_s.camelcase).constantize
end
end end
end end