Class: Jsapi::DSL::Path

Inherits:
Base
  • Object
show all
Includes:
SharedOperationMethods
Defined in:
lib/jsapi/dsl/path.rb

Instance Method Summary collapse

Methods included from SharedOperationMethods

#model, #parameter, #request_body, #response

Methods inherited from Base

#import, #import_relative, #initialize, #respond_to_missing?

Constructor Details

This class inherits a constructor from Jsapi::DSL::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Jsapi::DSL::Base

Instance Method Details

#operation(name = nil, **keywords, &block) ⇒ Object

Specifies an operation within this path.

operation 'foo' do
  parameter 'bar', type: 'string'
  response do
    property 'foo', type: 'string'
  end
end


22
23
24
25
26
27
28
29
# File 'lib/jsapi/dsl/path.rb', line 22

def operation(name = nil, **keywords, &block)
  define('operation', name&.inspect) do
    @meta_model.owner.add_operation(name, @meta_model.name, keywords)
                     .tap do |operation_model|
      Operation.new(operation_model, &block) if block
    end
  end
end

#path(name = nil, **keywords, &block) ⇒ Object

Specifies a nested path.



32
33
34
35
36
37
38
39
40
# File 'lib/jsapi/dsl/path.rb', line 32

def path(name = nil, **keywords, &block)
  define('path', name&.inspect) do
    name = @meta_model.name + name.to_s

    @meta_model.owner.add_path(name, keywords).tap do |path_model|
      Path.new(path_model, &block) if block
    end
  end
end