5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-14 18:11:41 +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
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