... | @@ -74,6 +74,9 @@ Enum::Roles.admin |
... | @@ -74,6 +74,9 @@ Enum::Roles.admin |
|
# Or you can get the list of values
|
|
# Or you can get the list of values
|
|
Enum::Roles.values
|
|
Enum::Roles.values
|
|
|
|
|
|
|
|
# You can also get all the values as symbols
|
|
|
|
Enum::Roles.keys
|
|
|
|
|
|
# Allows you to iterate over the values directly from the class
|
|
# Allows you to iterate over the values directly from the class
|
|
Enum::Roles.each do |role|
|
|
Enum::Roles.each do |role|
|
|
puts role
|
|
puts role
|
... | @@ -96,7 +99,8 @@ end |
... | @@ -96,7 +99,8 @@ end |
|
|
|
|
|
You are able to access the list of values trough the class that holds the enum:
|
|
You are able to access the list of values trough the class that holds the enum:
|
|
```ruby
|
|
```ruby
|
|
User.roles
|
|
User.roles # List of strings
|
|
|
|
User.roles_keys # List of symbols
|
|
```
|
|
```
|
|
|
|
|
|
You can set the column value from `String`, `Symbol`, and `Integer`:
|
|
You can set the column value from `String`, `Symbol`, and `Integer`:
|
... | | ... | |