Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hakanensari/double
Double allows you to use a constant before it is defined when metaprogramming
https://github.com/hakanensari/double
Last synced: 23 days ago
JSON representation
Double allows you to use a constant before it is defined when metaprogramming
- Host: GitHub
- URL: https://github.com/hakanensari/double
- Owner: hakanensari
- License: mit
- Created: 2012-06-15T12:24:59.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-06-21T12:47:45.000Z (over 12 years ago)
- Last Synced: 2024-10-09T16:46:10.604Z (about 1 month ago)
- Language: Ruby
- Homepage:
- Size: 150 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Double
[![travis][status]][travis]
## Description
Something can be [familiar, yet foreign at once][uncanny].
**Double** allows you to reference a constant before it is defined—a useful
trick when metaprogramming.## Usage
A contrived example:
```ruby
class Jekyll
extend Double# Gets/Sets the alter ego of the class.
#
# klass - A Class.
#
# Returns the Class alter ego.
def self.alter_ego(klass = nil)
klass ? @alter_ego = klass : @alter_ego
end
end# Open the class and set the alter ego:
class Jeykll
alter_ego Hyde
endJekyll.alter_ego # => #
# But who is this Hyde? Define him:
class Hyde; endJekyll.alter_ego # => Hyde
```[status]: https://secure.travis-ci.org/hakanensari/double.png
[travis]: http://travis-ci.org/hakanensari/double
[uncanny]: http://www-rohan.sdsu.edu/~amtower/uncanny.html