Method: PDK::Generate::PuppetObject#initialize

Defined in:
lib/pdk/generators/puppet_object.rb

#initialize(module_dir, object_name, options = {}) ⇒ PuppetObject

Initialises the PDK::Generate::PuppetObject object.

In general, this object should never be instantiated directly. Instead, one of the subclasses should be used e.g. PDK::Generate::Klass.

New subclasses generally only need to inherit this class, set the OBJECT_TYPE constant and implement the #template_data, #target_object_path and #target_spec_path methods.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/pdk/generators/puppet_object.rb', line 30

def initialize(module_dir, object_name, options = {})
  @module_dir = module_dir
  @options = options

  if [:class, :defined_type].include?(object_type) # rubocop:disable Style/GuardClause
    object_name_parts = object_name.split('::')

    @object_name = if object_name_parts.first == module_name
                     object_name
                   else
                     [module_name, object_name].join('::')
                   end
  end
end