Merge pull request #4115 from inspec/zenspider/clean_method_call_pattern

Stop using method(...).call(...)
This commit is contained in:
Miah Johnson 2019-05-20 13:07:43 -07:00 committed by GitHub
commit d1358df59f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 12 deletions

View file

@ -47,8 +47,8 @@ module Inspec::Resources
product_version file_version version? md5sum sha256sum
path basename source source_path uid gid
}.each do |m|
define_method m.to_sym do |*args|
file.method(m.to_sym).call(*args)
define_method m do |*args|
file.send(m, *args)
end
end

View file

@ -46,8 +46,8 @@ module Inspec::Resources
# Forward these methods directly to OpenSSL::X509::Certificate instance
%w{version not_before not_after signature_algorithm public_key}.each do |m|
define_method m.to_sym do |*args|
@cert.method(m.to_sym).call(*args)
define_method m do |*args|
@cert.send(m, *args)
end
end

View file

@ -250,10 +250,10 @@ module FilterTable
return [] if current_raw_data.empty?
method_ref = case desired_value
when Float then method(:matches_float)
when Integer then method(:matches_int)
when Regexp then method(:matches_regex)
else method(:matches)
when Float then :matches_float
when Integer then :matches_int
when Regexp then :matches_regex
else :matches
end
assume_symbolic_keyed_data = current_raw_data.first.keys.first.is_a? Symbol
@ -261,7 +261,7 @@ module FilterTable
current_raw_data.find_all do |row|
next unless row.key?(field)
method_ref.call(row[field], desired_value)
send(method_ref, row[field], desired_value)
end
end
@ -355,11 +355,11 @@ module FilterTable
# the tests are run.
methods_to_install_on_resource_class = @filter_methods + @custom_properties.keys
methods_to_install_on_resource_class.each do |method_name|
resource_class.send(:define_method, method_name.to_sym) do |*args, &block|
resource_class.send(:define_method, method_name) do |*args, &block|
begin
# self here is the resource instance
filter_table_instance = table_class.new(self, method(raw_data_fetcher_method_name).call, ' with')
filter_table_instance.method(method_name.to_sym).call(*args, &block)
filter_table_instance = table_class.new(self, send(raw_data_fetcher_method_name), ' with')
filter_table_instance.send(method_name, *args, &block)
rescue Inspec::Exceptions::ResourceFailed, Inspec::Exceptions::ResourceSkipped => e
FilterTable::ExceptionCatcher.new(resource_class, e)
end