Class: Controls::SecurityControlCoverage

Inherits:
Dish::Plate
  • Object
show all
Includes:
Comparable
Defined in:
lib/controls/objects/security_control_coverage.rb

Overview

A representation of the SecuritControl resource with coverage information

Instance Method Summary collapse

Instance Method Details

#<=>(other) ⇒ Fixnum

Allows for comparison with other objects with coverage information



16
17
18
19
# File 'lib/controls/objects/security_control_coverage.rb', line 16

def <=>(other)
  return unless other.respond_to? :coverage
  coverage.percent_covered <=> other.coverage.percent_covered
end

#respond_to?(method_name) ⇒ Boolean

review
  • shouldn’t this be covered by the Dish coercion?



24
25
26
27
28
29
30
# File 'lib/controls/objects/security_control_coverage.rb', line 24

def respond_to?(method_name, *)
  if method_name.eql? :coverage
    true
  else
    super
  end
end

#to_sString

The title of the security control



53
54
55
# File 'lib/controls/objects/security_control_coverage.rb', line 53

def to_s
  title
end

#without_coverageControls::SecurityControl

Converts the object into a Controls::SecurityControl by name and whether it is enabled/disabled



36
37
38
# File 'lib/controls/objects/security_control_coverage.rb', line 36

def without_coverage
  Controls::SecurityControl.new(enabled: enabled, name: name)
end

#without_coverage!Controls::SecurityControl

Removes the coverage from the Controls::SecurityControlCoverage object, making it equivalent to a Controls::SecurityControl in terms of duck-typing



44
45
46
47
48
# File 'lib/controls/objects/security_control_coverage.rb', line 44

def without_coverage!
  @_original_hash.delete_if do |key, _value|
    not %w[enabled name].include?(key)
  end
end