class ServiceContract::Avro::Protocol

Public Instance Methods

endpoints() click to toggle source
# File lib/service_contract/avro/protocol.rb, line 8
def endpoints
  avro.messages.map do |name, message|
    Endpoint.new(self, message)
  end
end
file_path() click to toggle source
# File lib/service_contract/avro/protocol.rb, line 4
def file_path
  File.join(service.data_dir, "#{name}.avpr")
end
main_type() click to toggle source
# File lib/service_contract/avro/protocol.rb, line 24
def main_type
  # convert protocol name to a class like name.  i.e. "city_state" => "CityState"
  name.split("_").map{|o| o.capitalize}.join
end
path() click to toggle source
# File lib/service_contract/avro/protocol.rb, line 20
def path
  File.join(service.path, resource_name)
end
types() click to toggle source
# File lib/service_contract/avro/protocol.rb, line 14
def types
  avro.types.map do |type|
    Type.build(type)
  end
end

Protected Instance Methods

avro() click to toggle source
# File lib/service_contract/avro/protocol.rb, line 35
def avro
  @avro ||= begin
    raise Errors::NotFound unless File.exists?(file_path)

    ::Avro::Protocol.parse(File.read(file_path))
  end
end
resource_name() click to toggle source
# File lib/service_contract/avro/protocol.rb, line 31
def resource_name
  name.respond_to?(:pluralize) ? name.pluralize : "#{name}s"
end