class DTK::DSL::Template::Loader
Constants
- TEMPLATE_VERSIONS
Public Class Methods
template_class(template_type, opts = {})
click to toggle source
opts can have keys
:dsl_version :template_version
# File lib/dsl/template/loader.rb, line 27 def self.template_class(template_type, opts = {}) template_version = opts[:template_version] || template_version(opts[:dsl_version]) load_version(template_version) unless version_loaded?(template_version) template_class_aux(template_type, template_version) end
Private Class Methods
load_version(template_version)
click to toggle source
# File lib/dsl/template/loader.rb, line 47 def self.load_version(template_version) require_relative("v#{template_version}") (@loaded_versions ||= []) << template_version end
template_class_aux(template_type, template_version)
click to toggle source
# File lib/dsl/template/loader.rb, line 52 def self.template_class_aux(template_type, template_version) base_class = Template.const_get("V#{template_version}") begin base_class.const_get(Aux.snake_to_camel_case(template_type.to_s)) rescue raise Error, "Invalid template_type '#{template_type}'" end end
template_version(_dsl_version)
click to toggle source
# File lib/dsl/template/loader.rb, line 39 def self.template_version(_dsl_version) # TODO: when have multiple versions thn want a mapping between # dsl version and template version, which could also be per template type # (i.e., same dsl version can map to different template versions depending on template_type) raise Error, "Unsupported when have multiple template versions" unless TEMPLATE_VERSIONS.size == 1 TEMPLATE_VERSIONS.first end
version_loaded?(template_version)
click to toggle source
# File lib/dsl/template/loader.rb, line 35 def self.version_loaded?(template_version) @loaded_versions and @loaded_versions.include?(template_version) end