Sha256: 43f72de9f8eb8b8720f687175dce8a9a33b1bbc97b5fdbd2f5a3053e78e8aa31
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
module ServiceContract module Avro class Type < AbstractType def name array? ? "Array(#{subtype.name})" : complex? ? definition.name : definition.type.to_s end def fields definition.fields.map do |field| Parameter.new(field) end end def to_s name end def subtype return nil unless definition.respond_to?(:items) Type.build(definition.items) end def array? type_string == "array" end def self.build(definition) Type.new(definition) end def complex? type_string == "record" end def valid_ruby_types case type_string when "array" [Array] when "int" [Fixnum] when "string" [String] when "float" [Float] when "boolean" [TrueClass, FalseClass] else # a complex type [Hash] end end protected def type_string type = definition.type type = type.type_sym.to_s if type.respond_to?(:type_sym) type end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
service_contract-0.0.10 | lib/service_contract/avro/type.rb |
service_contract-0.0.8 | lib/service_contract/avro/type.rb |