class Swagger::Data::Path

Attributes

ref[R]

Public Class Methods

parse(path) click to toggle source
# File lib/ruby-swagger/data/path.rb, line 11
def self.parse(path)
  raise ArgumentError.new('Swagger::Data::Path - path is nil') unless path

  res = Swagger::Data::Path.new.bulk_set(path)
  res.ref = path['$ref'] if path['$ref']
  res
end

Public Instance Methods

all_methods() click to toggle source
# File lib/ruby-swagger/data/path.rb, line 19
def all_methods
  [@get, @put, @post, @delete, @options, @head, @patch].compact
end
as_swagger() click to toggle source
Calls superclass method Swagger::Object#as_swagger
# File lib/ruby-swagger/data/path.rb, line 109
def as_swagger
  res = super
  res['$ref'] = @ref if @ref
  res
end
delete=(new_delete) click to toggle source
# File lib/ruby-swagger/data/path.rb, line 48
def delete=(new_delete)
  return nil unless new_delete
  unless new_delete.is_a?(Swagger::Data::Operation)
    new_delete = Swagger::Data::Operation.parse(new_delete)
  end
  @delete = new_delete
end
get=(new_get) click to toggle source
# File lib/ruby-swagger/data/path.rb, line 23
def get=(new_get)
  return nil unless new_get
  unless new_get.is_a?(Swagger::Data::Operation)
    new_get = Swagger::Data::Operation.parse(new_get)
  end

  @get = new_get
end
head=(new_head) click to toggle source
# File lib/ruby-swagger/data/path.rb, line 64
def head=(new_head)
  return nil unless new_head
  unless new_head.is_a?(Swagger::Data::Operation)
    new_head = Swagger::Data::Operation.parse(new_head)
  end

  @head = new_head
end
options=(new_options) click to toggle source
# File lib/ruby-swagger/data/path.rb, line 56
def options=(new_options)
  return nil unless new_options
  unless new_options.is_a?(Swagger::Data::Operation)
    new_options = Swagger::Data::Operation.parse(new_options)
  end
  @options = new_options
end
parameters=(new_parameters) click to toggle source
# File lib/ruby-swagger/data/path.rb, line 81
def parameters=(new_parameters)
  return nil unless new_parameters
  raise ArgumentError.new('Swagger::Data::Path#parameters= - parameters is not an array') unless new_parameters.is_a?(Array)

  @parameters = []

  new_parameters.each do |parameter|
    new_param = if parameter['$ref']
                  # it's a reference object
                  Swagger::Data::Reference.parse(parameter)
                else
                  # it's a parameter object
                  Swagger::Data::Parameter.parse(parameter)
                end

    @parameters.push(new_param)
  end
end
patch=(new_patch) click to toggle source
# File lib/ruby-swagger/data/path.rb, line 73
def patch=(new_patch)
  return nil unless new_patch
  unless new_patch.is_a?(Swagger::Data::Operation)
    new_patch = Swagger::Data::Operation.parse(new_patch)
  end
  @patch = new_patch
end
post=(new_post) click to toggle source
# File lib/ruby-swagger/data/path.rb, line 40
def post=(new_post)
  return nil unless new_post
  unless new_post.is_a?(Swagger::Data::Operation)
    new_post = Swagger::Data::Operation.parse(new_post)
  end
  @post = new_post
end
put=(new_put) click to toggle source
# File lib/ruby-swagger/data/path.rb, line 32
def put=(new_put)
  return nil unless new_put
  unless new_put.is_a?(Swagger::Data::Operation)
    new_put = Swagger::Data::Operation.parse(new_put)
  end
  @put = new_put
end
ref=(new_ref) click to toggle source
# File lib/ruby-swagger/data/path.rb, line 100
def ref=(new_ref)
  return nil unless new_ref
  raise ArgumentError.new('Swagger::Data::Path#ref= - $ref is not a string') unless new_ref.is_a?(String)

  @ref = new_ref
end