Module: ActiveAvro::Model

Defined in:
lib/active_avro/model.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

AVRO_TYPE_MAP =

Maps the Avro specification's primitive types to Ruby/Virtus types.

{
  :boolean => Axiom::Types::Boolean,  # See Virtus README caveat about Boolean
  :int     => Fixnum,
  :long    => Fixnum,
  :float   => BigDecimal,
  :double  => BigDecimal,
  :string  => String,
  :null    => NilClass
}

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object


22
23
24
25
26
27
28
29
30
31
32
# File 'lib/active_avro/model.rb', line 22

def self.included(base)
  base.send :include, Virtus.model  # TODO: allow options
  base.extend ClassMethods

  base.class_eval do
    # The Avro::Schema that defines de/serialization of this object.
    def avro_schema
      self.class.avro_schema
    end
  end
end