Class: OpenapiFirst::Coverage

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi_first/coverage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, spec) ⇒ Coverage

Returns a new instance of Coverage.



7
8
9
10
11
12
13
# File 'lib/openapi_first/coverage.rb', line 7

def initialize(app, spec)
  @app = app
  @spec = spec
  @to_be_called = spec.operations.map do |operation|
    endpoint_id(operation)
  end
end

Instance Attribute Details

#to_be_calledObject (readonly)

Returns the value of attribute to_be_called.



5
6
7
# File 'lib/openapi_first/coverage.rb', line 5

def to_be_called
  @to_be_called
end

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
20
# File 'lib/openapi_first/coverage.rb', line 15

def call(env)
  response = @app.call(env)
  operation = env[OPERATION]
  @to_be_called.delete(endpoint_id(operation)) if operation
  response
end