Module: RichEngine::Enum::Mixin::ClassMethods
- Defined in:
- lib/rich_engine/enum/mixin.rb
Overview
Class-level methods made available by including RichEngine::Enum::Mixin.
Instance Method Summary collapse
-
#enum(name, enum_options, enum_name: "#{name}s") ⇒ void
Declares an enum on the class.
Instance Method Details
#enum(name, enum_options, enum_name: "#{name}s") ⇒ void
This method returns an undefined value.
Declares an enum on the class. Defines a class method returning the RichEngine::Enum (named after +enum_name+) and an instance method (named +name+) that reads the +@name+ instance variable and returns the matching Value.
43 44 45 46 47 48 49 50 51 |
# File 'lib/rich_engine/enum/mixin.rb', line 43 def enum(name, , enum_name: "#{name}s") define_singleton_method(enum_name) do Enum.new(name, ) end define_method(name) do self.class.public_send(enum_name).public_send(instance_variable_get("@#{name}")) end end |