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:
parent
aa66e2cc9b
commit
0c6b85c030
1 changed files with 9 additions and 4 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue