File: UPGRADING.md

package info (click to toggle)
ruby-enum 0.9.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 196 kB
  • sloc: ruby: 410; makefile: 3
file content (44 lines) | stat: -rw-r--r-- 997 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Upgrading Ruby::Enum

## Upgrading to >= 0.9.0

### Inheritance & `Ruby::Enum.values`

This only applies to classes that inherit from another which is a `Ruby::Enum`.

Prior to version `0.9.0`, the `values` class method would enumerate only the
values defined in the class.

As of version `0.9.0`, the `values` class method enumerates values defined in
the entire class heirarchy, ancestors first.

``` ruby
class PrimaryColors
  include Ruby::Enum

  define :RED, 'RED'
  define :GREEN, 'GREEN'
  define :BLUE, 'BLUE'
end

class RainbowColors < PrimaryColors
  define :ORANGE, 'ORANGE'
  define :YELLOW, 'YELLOW'
  define :INIDGO, 'INIDGO'
  define :VIOLET, 'VIOLET'
end
```

`gem 'ruby-enum', '< 0.9.0'`

``` ruby
RainbowColors.values # ['ORANGE', 'YELLOW', 'INIDGO', 'VIOLET']
```

`gem 'ruby-enum', '>= 0.9.0'`

``` ruby
RainbowColors.values # ['RED', 'ORANGE', 'YELLOW', 'GREEN', 'BLUE', 'INIDGO', 'VIOLET']
```

See [#29](https://github.com/dblock/ruby-enum/pull/29) for more information.