Provides easy way for grouping constants into arrays
Add this line to your application's Gemfile:
gem 'magic-array'
And then execute:
$ bundle
Or install it yourself as:
$ gem install magic-array
class Foo
BAR_1 = 1
BAR_2 = 2
#...
BAR_N = Float::INFINITY
BARS = [
BAR_1,
BAR_2,
#...,
BAR_N
]
end
become
class Foo
BAR_1 = 1
BAR_2 = 2
#...
BAR_N = Float::INFINITY
BARS = from_existing /^BAR/ #[1, 2, ..., Infinity]
end
so after adding new constant (e.g. BAR_N+1
) you will not need to modify arrays constant.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request