Class: EasyType::Generators::EasyAttributeGenerator

Inherits:
EasyGenerator show all
Defined in:
lib/easy_type/generators/easy_attribute_generator.rb

Overview

Docs

Constant Summary collapse

ATTRIBUTE_TEMPLATE =
'easy_type_attribute.rb.erb'.freeze
END_PARAMETER_BLOCK =
/(^.*-- end of attributes --.*$)/
END_PARAMETER_TEXT =
"    # -- end of attributes -- Leave this comment if you want to use the scaffolder\n".freeze

Instance Method Summary collapse

Methods inherited from Base

#create_provider_directory, #create_type_directory, load

Methods included from Helpers

#camelize, #convert_csv_data_to_hash, #get_puppet_file, included

Methods included from PathHelpers

#attribute_path, #create_directory, #create_source, included, #modulepath, #name_attribute_path, #provider_directory, #provider_path, #puppet_lib, #puppet_lib?, #save_file, #shared_attribute_path, #template_path, #type_attribute_directory, #type_directory, #type_path, #type_shared_directory, #write_file

Constructor Details

#initialize(attribute_name, type_name, options) ⇒ EasyAttributeGenerator

Returns a new instance of EasyAttributeGenerator.



16
17
18
19
20
21
22
23
# File 'lib/easy_type/generators/easy_attribute_generator.rb', line 16

def initialize(attribute_name, type_name, options)
  super(type_name, options)
  @attribute_name   = attribute_name
  @attribute_type   = options.fetch(:attribute_type) { :parameter }
  @description      = options.fetch(:description) { 'A generated attribute' }
  @parameter_key    = options.fetch(:key) { @attribute_name }
  @shared           = options.key?(:shared)
end

Instance Method Details

#runObject

Run the scaffolder It created the directories and the nescessary files



29
30
31
32
33
# File 'lib/easy_type/generators/easy_attribute_generator.rb', line 29

def run
  super
  create_easy_attribute_source
  add_attribute_to_type
end