class ServiceContract::Avro::Endpoint

Public Instance Methods

description() click to toggle source
# File lib/service_contract/avro/endpoint.rb, line 9
def description
  [request_method, path].join(" ")
end
doc() click to toggle source
# File lib/service_contract/avro/endpoint.rb, line 13
def doc
  definition.respond_to?(:doc) ? definition.doc : nil
end
parameters() click to toggle source
# File lib/service_contract/avro/endpoint.rb, line 21
def parameters
  request.fields.map{|field| Parameter.new(field) }
end
response_type() click to toggle source
# File lib/service_contract/avro/endpoint.rb, line 17
def response_type
  Type.build(response)
end

Protected Instance Methods

member?() click to toggle source

seems kinda hacky

# File lib/service_contract/avro/endpoint.rb, line 61
def member?
  return false if parameters.empty?

  first_param_type = parameters.first.type
  first_param_type.is_a?(RecordType) && first_param_type.name == protocol.main_type
end
path() click to toggle source
# File lib/service_contract/avro/endpoint.rb, line 45
def path
  case name
  when "index", "create"
    protocol.path
  when "show", "destroy", "update"
    File.join(protocol.path, ":id")
  else
    if member?
      File.join(protocol.path, ":id", name)
    else
      File.join(protocol.path, name)
    end
  end
end
request_method() click to toggle source
# File lib/service_contract/avro/endpoint.rb, line 27
def request_method
  #Check for [<METHOD>] at the front of the doc string. this signals an action override
  if doc =~ /^\[([A-Z]+)\].+$/
    return $1
  end

  case name
  when "create"
    "POST"
  when "update"
    "PUT"
  when "destroy"
    "DELETE"
  else
    "GET"
  end
end