Class: Inspec::Resources::OpaApi

Inherits:
Opa show all
Defined in:
lib/inspec/resources/opa_api.rb

Instance Attribute Summary

Attributes inherited from JsonConfig

#params, #raw_content

Instance Method Summary collapse

Methods inherited from Opa

#result

Methods inherited from JsonConfig

#method_missing, #value

Methods included from FileReader

#read_file_content

Methods included from ObjectTraverser

#extract_value

Constructor Details

#initialize(opts = {}) ⇒ OpaApi

Returns a new instance of OpaApi.



9
10
11
12
13
14
15
# File 'lib/inspec/resources/opa_api.rb', line 9

def initialize(opts = {})
  @url = opts[:url] || nil
  @data = opts[:data] || nil
  fail_resource "OPA url and data are mandatory." if @url.nil? || @url.empty? || @data.nil? || @data.empty?
  @content = load_result
  super(@content)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Inspec::Resources::JsonConfig

Instance Method Details

#allowObject



17
18
19
# File 'lib/inspec/resources/opa_api.rb', line 17

def allow
  @content["result"]
end

#to_sObject



21
22
23
# File 'lib/inspec/resources/opa_api.rb', line 21

def to_s
  "OPA api"
end