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

Returns a new instance of Base.

Parameters:

  • _args (Array<Object>)


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

def initialize(*_args)
end

Class Method Details

.initialize_from_value(value) ⇒ SchemaClass::Base

Initializes this class from a given value

Parameters:

  • value (Object)

Returns:

Raises:



48
49
50
# File 'lib/deimos/schema_class/base.rb', line 48

def self.initialize_from_value(value)
  raise MissingImplementationError
end

Instance Method Details

#==(other) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


30
31
32
33
34
35
36
37
# File 'lib/deimos/schema_class/base.rb', line 30

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

  comparison == self.as_json
end

#[]=(key, val) ⇒ void

This method returns an undefined value.

Parameters:

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


24
25
26
# File 'lib/deimos/schema_class/base.rb', line 24

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.

Parameters:

  • _opts (Hash) (defaults to: {})

Returns:

  • (Hash)

    a hash representation of the payload

Raises:



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

def as_json(_opts={})
  raise MissingImplementationError
end

#inspectString

Returns:

  • (String)


40
41
42
43
# File 'lib/deimos/schema_class/base.rb', line 40

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