Class: Deimos::SchemaClass::Enum

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

Overview

Base Class for Enum Classes generated from Avro.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#[]=, #to_s

Constructor Details

#initialize(value) ⇒ Enum

Returns a new instance of Enum.

Parameters:

  • value (String)


19
20
21
# File 'lib/deimos/schema_class/enum.rb', line 19

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



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

def value
  @value
end

Class Method Details

.initialize_from_value(value) ⇒ Object

:nodoc:



35
36
37
38
39
# File 'lib/deimos/schema_class/enum.rb', line 35

def self.initialize_from_value(value)
  return nil if value.nil?

  value.is_a?(self) ? value : self.new(value)
end

Instance Method Details

#==(other) ⇒ Object

Parameters:



14
15
16
# File 'lib/deimos/schema_class/enum.rb', line 14

def ==(other)
  other.is_a?(self.class) ? other.value == @value : other == @value
end

#as_json(_opts = {}) ⇒ Object

:nodoc:



30
31
32
# File 'lib/deimos/schema_class/enum.rb', line 30

def as_json(_opts={})
  @value
end

#symbolsArray<String>

Returns all the valid symbols for this enum.

Returns:

  • (Array<String>)

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/deimos/schema_class/enum.rb', line 25

def symbols
  raise NotImplementedError
end