Class: ENM::Enum

Inherits:
Object
  • Object
show all
Extended by:
Dry::Core::Cache
Includes:
Enumerable
Defined in:
lib/enm/enum.rb

Overview

An enum type from the database.

Defined Under Namespace

Classes: DryTypeBuilder

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commentString? (readonly)

Returns comment associated with the enum type.

Returns:

  • (String, nil)

    comment associated with the enum type



# File 'lib/enm/enum.rb', line 11

#digestString (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a digest representing the enum values, for caching purposes.

Returns:

  • (String)

    a digest representing the enum values, for caching purposes



# File 'lib/enm/enum.rb', line 14

#nameString (readonly)

Returns the name of the enum type.

Returns:

  • (String)

    the name of the enum type



# File 'lib/enm/enum.rb', line 18

#schemaString (readonly)

Returns the schema of the enum type.

Returns:

  • (String)

    the schema of the enum type



# File 'lib/enm/enum.rb', line 21

Instance Method Details

#dry(default: nil, mode: :string) ⇒ Dry::Types::Type

Parameters:

  • default (String, Symbol, #to_s, #to_sym, nil) (defaults to: nil)

    whether to use a certain value as dry-type's default, since it must be defined before the enum call.

  • mode (:string, :symbol) (defaults to: :string)

    the underlying type of the enum values.

Returns:

  • (Dry::Types::Type)

See Also:



30
31
32
33
34
# File 'lib/enm/enum.rb', line 30

def dry(default: nil, mode: :string)
  fetch_or_store([digest, default, mode]) do
    DryTypeBuilder.new(self, mode:, default:).()
  end
end