Class: AbideDataProcessor::Parser::ProcessorObject

Inherits:
Object
  • Object
show all
Includes:
Validation
Defined in:
lib/abide-data-processor/parser.rb

Overview

This class holds all base attributes and methods for every syntax object. rubocop:disable Metrics/ClassLength

Direct Known Subclasses

Control, Resource

Instance Method Summary collapse

Methods included from Validation

#array_of_hashes?, #not_nil_or_empty?, #validate_control_maps, #validate_hiera_data

Constructor Details

#initialize(name, data, control_maps) ⇒ ProcessorObject

Returns a new instance of ProcessorObject.



283
284
285
286
287
288
289
# File 'lib/abide-data-processor/parser.rb', line 283

def initialize(name, data, control_maps)
  @name = name
  @data = validate_hiera_data(data)
  @control_maps = validate_control_maps(control_maps)
  @dependent = Set.new
  initialize_metaparams(@data, @control_maps)
end

Instance Method Details

#after_meArray

Returns any Resource objects that must be ordered after this object.

Returns:

  • (Array)

    The Resources that must be ordered after this object.



314
315
316
# File 'lib/abide-data-processor/parser.rb', line 314

def after_me
  defined?(@after_me) ? @after_me : initialize_after_me
end

#before_meArray

Returns any Resource objects that must be ordered before this object.

Returns:

  • (Array)

    The Resources that must be ordered before this object.



308
309
310
# File 'lib/abide-data-processor/parser.rb', line 308

def before_me
  defined?(@before_me) ? @before_me : initialize_before_me
end

#inspectString

Gives a more detailed String representation of this object.

Returns:

  • (String)

    The class, object id, and name of this object.



326
327
328
# File 'lib/abide-data-processor/parser.rb', line 326

def inspect
  "#<#{self.class.name}:#{object_id} '#{@name}'>"
end

#name?(_name) ⇒ Boolean

Determines if the name supplied is equal to the name of the object. This is overridden by subclasses to implement name mapped matches.

Parameters:

  • name (String)

    The name to be compared to the object's name.

Returns:

  • (Boolean)

    True if the name is equal to the object's name, false otherwise.

Raises:

  • (NotImplementedError)


295
296
297
# File 'lib/abide-data-processor/parser.rb', line 295

def name?(_name)
  raise NotImplementedError, 'This method must be implemented by a subclass'
end

#resource_dataObject

Abstract method to be implemented by subclasses. Returns a representation of this object as a Hash usable by Puppet's create_resources function.

Raises:

  • (NotImplementedError)


302
303
304
# File 'lib/abide-data-processor/parser.rb', line 302

def resource_data
  raise NotImplementedError, 'This method must be implemented by a subclass'
end

#to_sString

Converts this object to a String.

Returns:

  • (String)

    The class and name of this object.



320
321
322
# File 'lib/abide-data-processor/parser.rb', line 320

def to_s
  "#{self.class.name}('#{@name}')"
end