lib/metatron/template.rb in metatron-0.2.0 vs lib/metatron/template.rb in metatron-0.2.1
- old
+ new
@@ -16,11 +16,11 @@
def initialize(name)
@name = name
@label_namespace = self.class.label_namespace
@api_version = "v1"
- @kind = self.class.name.split("::").last
+ @kind = find_kind
run_initializers
end
alias apiVersion api_version
@@ -35,8 +35,18 @@
private
def run_initializers
self.class.initializers.each { |initializer| send(initializer.to_sym) }
+ end
+
+ def find_kind
+ return self.class.name.split("::").last if metatron_template?
+
+ self.class.ancestors.find { |klass| metatron_template?(klass) }.name.split("::").last
+ end
+
+ def metatron_template?(klass = self)
+ klass.name.include?("Metatron::Templates") && !klass.name.include?("Concerns")
end
end
end