Sha256: c6c2885302836099702d32c13e1d1c9f0d44a0fd978379145b7f9e72ef866ca9
Contents?: true
Size: 1.87 KB
Versions: 1
Compression:
Stored size: 1.87 KB
Contents
= InstanceVariableHash {<img src="https://secure.travis-ci.org/metakeule/instance_variable_hash.png" />}[https://secure.travis-ci.org/metakeule/instance_variable_hash] == What is it for? You might have attributes (in a plugin for example) that you want to use as Hash. But if you want to set these attribute from the outside it will be difficult to set parts of this hash at different places. So it would be better to have all attributes as simple values and have a naming convention that allows conversion into hashes if needed. Instead of @config = { :a => {:b => 'val_b', :c => ['c1', 'c2']} } you would do @a_b = 'val_b' @a_c = ['c1', 'c2'] and with this lib you would have a shortcut that allows you to pass a hash: ivars_from_hash({ :a => {:b => 'val_b', :c => ['c1', 'c2']} }) to get them back as a hash ivars_to_hash('a') # => {:b => 'val_b', :c => ['c1', 'c2']} } To use the lib: require 'rubygems' require 'instance_variable_hash' # you might want to use it only for certain classes / objects class Object include InstanceVariableHash end That's all. A very simple library, tested with ruby 1.8 and 1.9. == Contributing * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it * Fork the project * Start a feature/bugfix branch * Commit and push until you are happy with your contribution * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally. * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it. == Copyright Copyright (c) 2011 Marc Rene Arns. See LICENSE.txt for further details.
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
instance_variable_hash-1.1.0 | README.rdoc |