mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-25 13:36: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
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue