Revert to a small amount of duplicating to_hash in inspec/input.rb

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
Clinton Wolfe 2019-10-06 19:30:37 -04:00
parent 11074bb7ce
commit 88ed1794cb
3 changed files with 13 additions and 2 deletions

View file

@ -318,6 +318,17 @@ module Inspec
!current_value.is_a? NO_VALUE_SET !current_value.is_a? NO_VALUE_SET
end end
def to_hash
as_hash = { name: name, options: {} }
%i{description title identifier type required value}.each do |field|
val = send(field)
next if val.nil?
as_hash[:options][field] = val
end
as_hash
end
#--------------------------------------------------------------------------# #--------------------------------------------------------------------------#
# Value Type Coercion # Value Type Coercion
#--------------------------------------------------------------------------# #--------------------------------------------------------------------------#

View file

@ -1,6 +1,6 @@
require "forwardable" require "forwardable"
require "singleton" require "singleton"
require "inspec/objects/input" require "inspec/input"
require "inspec/secrets" require "inspec/secrets"
require "inspec/exceptions" require "inspec/exceptions"
require "inspec/plugin/v2" require "inspec/plugin/v2"

View file

@ -1,5 +1,5 @@
require "helper" require "helper"
require "inspec/objects/input" require "inspec/input"
describe Inspec::Input do describe Inspec::Input do
let(:opts) { {} } let(:opts) { {} }