module Enumbler::Enabler
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.
Public Instance Methods
enumble()
click to toggle source
The Enumble
definition that this record defined. @return [Enumbler::Enumble]
# 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()
click to toggle source
The enumble graphql_enum if it exists. @return [Symbol]
Calls superclass method
# File lib/enumbler/enabler.rb, line 22 def to_graphql_enum to_enumble_attribute(:graphql_enum) || super end
to_s()
click to toggle source
The enumble label if it exists. @return [String]
Calls superclass method
# File lib/enumbler/enabler.rb, line 28 def to_s to_enumble_attribute(:label) || super end
to_sym()
click to toggle source
The enumble symbol if it exists. @return [Symbol]
Calls superclass method
# File lib/enumbler/enabler.rb, line 34 def to_sym to_enumble_attribute(:enum) || super end
Private Instance Methods
to_enumble_attribute(attribute)
click to toggle source
# File lib/enumbler/enabler.rb, line 40 def to_enumble_attribute(attribute) enumble = self.class.find_enumble(id) return enumble.send(attribute) if enumble.present? end