Class: CemSpecHelper::ResourceDataSpec::Resource
- Inherits:
-
Object
- Object
- CemSpecHelper::ResourceDataSpec::Resource
- Defined in:
- lib/cem_spec_helper/resource_data_spec.rb
Overview
The Resource class represents a single resource from the resource data file
Instance Attribute Summary collapse
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#controls(include_special: true) ⇒ Array<String>
An array of control names implemented by the resource.
-
#initialize(title, data) ⇒ Resource
constructor
A new instance of Resource.
-
#params ⇒ Hash
A hash of parameter names => default values.
-
#verify_no_duplicate_controls ⇒ TrueClass, FalseClass
Whether or not the resource has any duplicate control names.
Constructor Details
#initialize(title, data) ⇒ Resource
Returns a new instance of Resource.
231 232 233 234 235 236 237 |
# File 'lib/cem_spec_helper/resource_data_spec.rb', line 231 def initialize(title, data) @title = title @data = data @type = @data['type'] @no_params = false @control_data = load_control_data end |
Instance Attribute Details
#title ⇒ Object (readonly)
Returns the value of attribute title.
227 228 229 |
# File 'lib/cem_spec_helper/resource_data_spec.rb', line 227 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
227 228 229 |
# File 'lib/cem_spec_helper/resource_data_spec.rb', line 227 def type @type end |
Instance Method Details
#controls(include_special: true) ⇒ Array<String>
Returns An array of control names implemented by the resource.
241 242 243 244 245 246 |
# File 'lib/cem_spec_helper/resource_data_spec.rb', line 241 def controls(include_special: true) ctrls = @no_params ? @control_data : @control_data.keys return ctrls if include_special ctrls.reject { |c| SPECIAL_CONTROLS.include?(c) } end |
#params ⇒ Hash
Returns A hash of parameter names => default values.
249 250 251 252 253 |
# File 'lib/cem_spec_helper/resource_data_spec.rb', line 249 def params # rubocop:disable Style/CollectionMethods control_data.map { |_, v| v if v.is_a?(Hash) }.flatten.compact.uniq.inject(:merge) # rubocop:enable Style/CollectionMethods end |
#verify_no_duplicate_controls ⇒ TrueClass, FalseClass
Returns Whether or not the resource has any duplicate control names.
256 257 258 |
# File 'lib/cem_spec_helper/resource_data_spec.rb', line 256 def verify_no_duplicate_controls controls.uniq == controls end |