mirror of
https://github.com/inspec/inspec
synced 2025-02-17 06:28:40 +00:00
Merge pull request #4115 from inspec/zenspider/clean_method_call_pattern
Stop using method(...).call(...)
This commit is contained in:
commit
d1358df59f
3 changed files with 12 additions and 12 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue