Class: AbideDataProcessor::Parser::Control

Inherits:
ProcessorObject show all
Defined in:
lib/abide-data-processor/parser.rb

Overview

This class represents a single control in the data structure.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ProcessorObject

#after_me, #before_me, #inspect, #to_s

Methods included from Validation

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

Constructor Details

#initialize(name, data, control_maps) ⇒ Control

Returns a new instance of Control.



498
499
500
501
502
503
504
# File 'lib/abide-data-processor/parser.rb', line 498

def initialize(name, data, control_maps)
  super(name, data, control_maps)
  @mapped_names = find_mapped_names(@name)
  @params = @data == :no_params ? {} : @data
  @resource_params = @data == :no_params ? {} : @data.reject { |k, _v| METAPARAMS.include?(k) }
  @param_names = @data == :no_params ? Set.new : Set.new(@params.keys)
end

Instance Attribute Details

#mapped_namesObject (readonly)

Returns the value of attribute mapped_names.



496
497
498
# File 'lib/abide-data-processor/parser.rb', line 496

def mapped_names
  @mapped_names
end

#param_namesObject (readonly)

Returns the value of attribute param_names.



496
497
498
# File 'lib/abide-data-processor/parser.rb', line 496

def param_names
  @param_names
end

#paramsObject (readonly)

Returns the value of attribute params.



496
497
498
# File 'lib/abide-data-processor/parser.rb', line 496

def params
  @params
end

#resource_paramsObject (readonly)

Returns the value of attribute resource_params.



496
497
498
# File 'lib/abide-data-processor/parser.rb', line 496

def resource_params
  @resource_params
end

Instance Method Details

#name?(name) ⇒ Boolean

Returns:

  • (Boolean)


506
507
508
# File 'lib/abide-data-processor/parser.rb', line 506

def name?(name)
  @name == name || @mapped_names.include?(name)
end

#param(param_name) ⇒ Object



514
515
516
# File 'lib/abide-data-processor/parser.rb', line 514

def param(param_name)
  @params[param_name]
end

#param?(param_name) ⇒ Boolean

Returns:

  • (Boolean)


510
511
512
# File 'lib/abide-data-processor/parser.rb', line 510

def param?(param_name)
  @param_names.include?(param_name)
end

#resource_dataObject



518
519
520
# File 'lib/abide-data-processor/parser.rb', line 518

def resource_data
  @resource_params
end