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
-
#enumble ⇒ Enumbler::Enumble
The Enumble definition that this record defined.
-
#to_graphql_enum ⇒ Symbol
The enumble graphql_enum if it exists.
-
#to_s ⇒ String
The enumble label if it exists.
-
#to_sym ⇒ Symbol
The enumble symbol if it exists.
Instance Method Details
#enumble ⇒ Enumbler::Enumble
The Enumble definition that this record defined.
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_enum ⇒ Symbol
The enumble graphql_enum if it exists.
22 23 24 |
# File 'lib/enumbler/enabler.rb', line 22 def to_graphql_enum to_enumble_attribute(:graphql_enum) || super end |
#to_s ⇒ String
The enumble label if it exists.
28 29 30 |
# File 'lib/enumbler/enabler.rb', line 28 def to_s to_enumble_attribute(:label) || super end |
#to_sym ⇒ Symbol
The enumble symbol if it exists.
34 35 36 |
# File 'lib/enumbler/enabler.rb', line 34 def to_sym to_enumble_attribute(:enum) || super end |