Class: Jsapi::DSL::Path

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

Instance Method Summary collapse

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 the current path.

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


15
16
17
18
19
20
# File 'lib/jsapi/dsl/path.rb', line 15

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

#parameter(name, **keywords, &block) ⇒ Object

Specifies a parameter applicable for all operations in this path.

parameter 'foo', type: 'string'

See Meta::Path#parameters for further information.



27
28
29
30
31
32
# File 'lib/jsapi/dsl/path.rb', line 27

def parameter(name, **keywords, &block)
  define('parameter', name.inspect) do
    parameter_model = @meta_model.add_parameter(name, keywords)
    Parameter.new(parameter_model, &block) if block
  end
end

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

Specifies a nested path.



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

def path(name = nil, &block)
  define('path', name&.inspect) do
    path_model = @meta_model.owner.add_path(@meta_model.name + name.to_s)
    Path.new(path_model, &block) if block
  end
end