0.0
No commit activity in last 3 years
No release in over 3 years
Define class and instance methods for consts access
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
= 3.0.0.beta2
 Project Readme

HandyConst Gem Version Build Status Code Climate

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

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request