Sha256: 9d29fc0422ed89804865d9b89963ec3820ac3cefe1299c79ed53de90c9f27d8a

Contents?: true

Size: 771 Bytes

Versions: 5

Compression:

Stored size: 771 Bytes

Contents

module ServiceContract
  module Avro
    class Protocol < AbstractProtocol
      def file_path
        File.join(service.data_dir, "#{name}.avpr")
      end

      def endpoints
        avro.messages.map do |name, message|
          Endpoint.new(self, message)
        end
      end

      def types
        avro.types.map do |type|
          Type.new(type)
        end
      end

      def path
        File.join(service.path, resource_name)
      end

      protected

      def resource_name
        name.respond_to?(:pluralize) ? name.pluralize : "#{name}s"
      end

      def avro
        @avro ||= begin
          raise Errors::NotFound unless File.exists?(file_path)

          ::Avro::Protocol.parse(File.read(file_path))
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
service_contract-0.0.10 lib/service_contract/avro/protocol.rb
service_contract-0.0.8 lib/service_contract/avro/protocol.rb
service_contract-0.0.7 lib/service_contract/avro/protocol.rb
service_contract-0.0.6 lib/service_contract/avro/protocol.rb
service_contract-0.0.5 lib/service_contract/avro/protocol.rb