kattr like attr_* but for class methods
Ruby
Switch branches/tags
Nothing to show
Pull request Compare This branch is 12 commits ahead of danielb2:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.gitignore
.rspec
.ruby-version.example
.travis.yml
Gemfile
LICENSE
README.markdown
Rakefile
kattr.gemspec

README.markdown

kattr

Build Status

Works much like the version for rails (except it doesn't accept blocks and doesn't use eval).

I prefer to use kattr_* instead of cattr_* so there are no confusion with cattr_* in Rails. Note, both cattr_* and kattr_* will work just fine.

If you are using this gem outside of Rails you should be all right

Example

require 'kattr'

class Moo
  extend KAttr
  kattr_accessor :cow
end

Moo.cow = 'animal'
Moo.class_variables
#=> [:@@cow]

You can either add kattr to your $LOAD_PATH or use it as in the example

Note on Patches/Pull Requests

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

Thanks

danielb2 for the original implementation

Copyright

Copyright (c) 2012 Teo Ljungberg. See LICENSE for details.