Class: Inspec::Resources::SecurityIdentifier
- Inherits:
-
Object
- Object
- Inspec::Resources::SecurityIdentifier
- Defined in:
- lib/inspec/resources/security_identifier.rb
Instance Method Summary collapse
- #exist? ⇒ Boolean
-
#initialize(opts = {}) ⇒ SecurityIdentifier
constructor
A new instance of SecurityIdentifier.
- #resource_id ⇒ Object
- #sid ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ SecurityIdentifier
Returns a new instance of SecurityIdentifier.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/inspec/resources/security_identifier.rb', line 17 def initialize(opts = {}) supported_opt_keys = %i{user group unspecified} raise ArgumentError, "Invalid security_identifier param '#{opts}'. Please pass a hash with these supported keys: #{supported_opt_keys}" unless opts.respond_to?(:keys) raise ArgumentError, "Unsupported security_identifier options '#{opts.keys - supported_opt_keys}'. Supported keys: #[supported_opt_keys]" unless (opts.keys - supported_opt_keys).empty? raise ArgumentError, "Specifying more than one of :user :group or :unspecified for security_identifier is not supported" unless opts.keys && (opts.keys & supported_opt_keys).length == 1 if opts[:user] @type = :user @name = opts[:user] end if opts[:group] @type = :group @name = opts[:group] end if opts[:unspecified] @type = :unspecified @name = opts[:unspecified] end raise ArgumentError, "Specify one of :user :group or :unspecified for security_identifier" unless @name @sids = nil end |
Instance Method Details
#exist? ⇒ Boolean
45 46 47 48 |
# File 'lib/inspec/resources/security_identifier.rb', line 45 def exist? fetch_sids unless @sids @sids.key?(@name) end |
#resource_id ⇒ Object
54 55 56 |
# File 'lib/inspec/resources/security_identifier.rb', line 54 def resource_id @name end |
#sid ⇒ Object
40 41 42 43 |
# File 'lib/inspec/resources/security_identifier.rb', line 40 def sid fetch_sids unless @sids @sids[@name] # nil if not found end |
#to_s ⇒ Object
50 51 52 |
# File 'lib/inspec/resources/security_identifier.rb', line 50 def to_s "Security Identifier" end |