shared.rb provides a super easy way to share code between classes or modules in a simple way.
ahoward/shared
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
master
Could not load branches
Nothing to show
Could not load tags
Nothing to show
{{ refName }}
default
Code
-
Clone
Use Git or checkout with SVN using the web URL.
Work fast with our official CLI. Learn more.
- Open with GitHub Desktop
- Download ZIP
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
NAME shared.rb DESCRIPTION shared.rb provides a super easy way to share code between classes or modules in a simple way. shared code can be at the class and/or instance level and users deferred evaluation so this is more powerful that the normal ruby module inclusion facilities on which it is based. SYNOPSIS require 'shared' Shared 'methods' do class << self attr :classname end @classname = name.downcase def objectname self.class.classname + "(#{ object_id })" end end class C include Shared('methods') end class B include Shared('methods') end p C.classname #=> 'c' p C.new.objectname #=> 'c(1234)' p B.classname #=> 'b' p B.new.objectname #=> 'b(4567)'
About
shared.rb provides a super easy way to share code between classes or modules in a simple way.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published