Module: Enumbler::Enabler

Extended by:
ActiveSupport::Concern
Defined in:
lib/enumbler/enabler.rb

Overview

Extending this module bestows the power of the ‘enumbler` to the underlying model. For example, if you have a model `Color` you would include the `Enabler` to support the different colors your `Color` model represents.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#enumbleEnumbler::Enumble

The Enumble definition that this record defined.

Returns:

Raises:



12
13
14
15
16
17
18
# File 'lib/enumbler/enabler.rb', line 12

def enumble
  @enumble = self.class.find_enumble(id)

  raise Error, "An enumble is not defined for this record!" if @enumble.nil?

  @enumble
end

#to_graphql_enumSymbol

The enumble graphql_enum if it exists.

Returns:



22
23
24
# File 'lib/enumbler/enabler.rb', line 22

def to_graphql_enum
  to_enumble_attribute(:graphql_enum) || super
end

#to_sString

The enumble label if it exists.

Returns:

  • (String)


28
29
30
# File 'lib/enumbler/enabler.rb', line 28

def to_s
  to_enumble_attribute(:label) || super
end

#to_symSymbol

The enumble symbol if it exists.

Returns:



34
35
36
# File 'lib/enumbler/enabler.rb', line 34

def to_sym
  to_enumble_attribute(:enum) || super
end