Magic::Array
Provides easy way for grouping constants into arrays
Installation
Add this line to your application's Gemfile:
gem 'magic-array'
And then execute:
$ bundle
Or install it yourself as:
$ gem install magic-array
Usage
from_existing(pattern)
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/
end
so after adding new constant (e.g. BAR_N+1
) you will not need to modify arrays constant.
Contributing
- 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