Sha256: bfd90ab817346b0e1454146cc0edd22b80c5d6c8bc2c8706ba27437d72fbef63

Contents?: true

Size: 1001 Bytes

Versions: 38

Compression:

Stored size: 1001 Bytes

Contents

# frozen_string_literal: true

require_relative 'base'
require 'json'

module Deimos
  module SchemaClass
    # Base Class for Enum Classes generated from Avro.
    class Enum < Base

      # @return [String]
      attr_accessor :value

      # @param other [Deimos::SchemaClass::Enum]
      # @return [Boolean]
      def ==(other)
        other.is_a?(self.class) ? other.value == @value : other == @value
      end

      # @return [String]
      def to_s
        @value.to_s
      end

      # @param value [String]
      def initialize(value)
        @value = value
      end

      # Returns all the valid symbols for this enum.
      # @return [Array<String>]
      def symbols
        raise NotImplementedError
      end

      # @return [String]
      def as_json(_opts={})
        @value
      end

      # @return [SchemaClass::Enum]
      def self.initialize_from_value(value)
        return nil if value.nil?

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

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
deimos-ruby-1.24.2 lib/deimos/schema_class/enum.rb
deimos-ruby-1.24.1 lib/deimos/schema_class/enum.rb
deimos-ruby-1.24.0 lib/deimos/schema_class/enum.rb
deimos-ruby-1.23.3 lib/deimos/schema_class/enum.rb
deimos-ruby-1.23.2 lib/deimos/schema_class/enum.rb
deimos-ruby-1.23.1.pre.beta6 lib/deimos/schema_class/enum.rb
deimos-ruby-1.23.1.pre.beta5 lib/deimos/schema_class/enum.rb
deimos-ruby-1.23.1.pre.beta4 lib/deimos/schema_class/enum.rb
deimos-ruby-1.23.1.pre.beta3 lib/deimos/schema_class/enum.rb
deimos-ruby-1.23.1.pre.beta2 lib/deimos/schema_class/enum.rb
deimos-ruby-1.23.1.pre.beta1 lib/deimos/schema_class/enum.rb
deimos-ruby-1.23.0 lib/deimos/schema_class/enum.rb
deimos-ruby-1.22.5 lib/deimos/schema_class/enum.rb
deimos-ruby-1.22.4 lib/deimos/schema_class/enum.rb
deimos-ruby-1.22.3 lib/deimos/schema_class/enum.rb
deimos-ruby-1.22.2 lib/deimos/schema_class/enum.rb
deimos-ruby-1.22.1 lib/deimos/schema_class/enum.rb
deimos-ruby-1.22 lib/deimos/schema_class/enum.rb
deimos-ruby-1.20.1 lib/deimos/schema_class/enum.rb
deimos-ruby-1.20.0 lib/deimos/schema_class/enum.rb