lib/metatron/template.rb in metatron-0.6.0 vs lib/metatron/template.rb in metatron-0.6.1

- old
+ new

@@ -10,10 +10,32 @@ attr_writer :label_namespace def label_namespace @label_namespace ||= "metatron.therubyist.org" end + + def initializer(*args) + @initializers ||= [] + @initializers += args + end + + def initializers + @initializers ||= [] + end + + def nearest_metatron_ancestor + return self if metatron_template_class? + + ancestors.find { _1.respond_to?(:metatron_template_class?) && _1.metatron_template_class? } + end + + def metatron_template_class? + return true if name == "Metatron::Template" + return false if name.start_with?("Metatron::Templates::Concerns") + + name.start_with?("Metatron::Templates::") + end end def initialize(name) @name = name @label_namespace = self.class.label_namespace @@ -23,30 +45,10 @@ run_initializers end alias apiVersion api_version - def self.initializer(*args) - @initializers ||= [] - @initializers += args - end - - def self.initializers - @initializers ||= [] - end - - def self.nearest_metatron_ancestor - return self if metatron_template_class? - - ancestors.find { _1.respond_to?(:metatron_template_class?) && _1.metatron_template_class? } - end - - def self.metatron_template_class? - return true if name == "Metatron::Template" - return false if name.start_with?("Metatron::Templates::Concerns") - - name.start_with?("Metatron::Templates::") - end + def base_labels = { "#{label_namespace}/name": name } private def run_initializers self.class.nearest_metatron_ancestor.initializers.each { send(_1.to_sym) }