Class: Icss::TypeFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/icss/type.rb

Overview

Avro Schema Declaration

A Schema is represented in JSON by one of:

  • A JSON string, naming a defined type.

  • A JSON object, of the form:

    {"type": "typeName" ...attributes...}
    

    where typeName is either a primitive or derived type name, as defined in the Icss::Type class

  • A JSON array, representing a union of embedded types.

Class Method Summary collapse

Class Method Details

.receive(type_info) ⇒ Object



205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/icss/type.rb', line 205

def self.receive type_info
  # p ['----------', self, 'receive', type_info, Icss::Type::DERIVED_TYPES] if type_info.is_a?(String) && type_info =~ /abstr/
  case
  when type_info.is_a?(Icss::Type)
    type_info
  when type_info.is_a?(String) || type_info.is_a?(Symbol)
    Icss::Type.find(type_info)
  when type_info.is_a?(Array)
    UnionType.receive(type_info)
  else
    type_info  = type_info.symbolize_keys
    raise "No type was given in #{type_info.inspect}" if type_info[:type].blank?
    type_name = type_info[:type].to_sym
    type = Icss::Type.find(type_name)
    obj  = type.receive(type_info)
  end
end