Created
September 26, 2008 12:12
-
-
Save dchelimsky/13087 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module InstanceVariableHelpers | |
| def set_ivar(type, name, obj) | |
| instance_variable_set ivar_name(type, name), obj | |
| end | |
| def get_ivar(type, name) | |
| returning instance_variable_get(ivar_name(type, name)) do |obj| | |
| yield obj if block_given? | |
| end | |
| end | |
| private | |
| def ivar_name(type, name) | |
| "@#{type}_#{name.gsub(/[ -]/,'_').gsub('&','and')}" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment