Easy class and instance methods definition for consts access. And no more freeze!
Installation
Add to Gemfile:
gem 'handy_const'
Usage
Include HandyConst in your class and define some constants
class Foo
include HandyConst
const :foo, 'foo'
end
# Const
Foo::FOO
=> "foo"
# Class method
Foo.foo
=> "foo"
# Instance method
Foo.new.foo
=> "foo"
# Frozen for you!
Foo.foo.frozen?
=> true
Call HandyConst.extend_module!
if you want to make available const
method in any class and module
HandyConst.extend_module!
class Bar
const :bar, 'bar'
end
Bar::BAR
# => "bar"
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