Class: Deimos::SchemaClass::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/deimos/schema_class/base.rb

Overview

Base Class for Schema Classes generated from Avro.

Direct Known Subclasses

Enum, Record

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*_args) ⇒ Base

:nodoc:



11
12
# File 'lib/deimos/schema_class/base.rb', line 11

def initialize(*_args)
end

Class Method Details

.initialize_from_value(value) ⇒ Object

Initializes this class from a given value

Parameters:

  • value (Object)

Raises:

  • (NotImplementedError)


44
45
46
# File 'lib/deimos/schema_class/base.rb', line 44

def self.initialize_from_value(value)
  raise NotImplementedError
end

Instance Method Details

#==(other) ⇒ Object

:nodoc:



27
28
29
30
31
32
33
34
# File 'lib/deimos/schema_class/base.rb', line 27

def ==(other)
  comparison = other
  if other.class == self.class
    comparison = other.as_json
  end

  comparison == self.as_json
end

#[]=(key, val) ⇒ Object

Parameters:

  • key (String|Symbol)
  • val (Object)


22
23
24
# File 'lib/deimos/schema_class/base.rb', line 22

def []=(key, val)
  self.send("#{key}=", val)
end

#as_json(_opts = {}) ⇒ Hash

Converts the object to a hash which can be used for debugging or comparing objects.

Returns:

  • (Hash)

    a hash representation of the payload

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/deimos/schema_class/base.rb', line 16

def as_json(_opts={})
  raise NotImplementedError
end

#to_sObject

:nodoc:



37
38
39
40
# File 'lib/deimos/schema_class/base.rb', line 37

def to_s
  klass = self.class
  "#{klass}(#{self.as_json})"
end