Rubygoods
Some utils for Ruby
Installation
Add this line to your application's Gemfile:
gem 'rubygoods'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rubygoods
Usage
This library includes:
- Some kind of logger
- Shortcut for gem-version getter
- Multi-Class Proxy
RG::Utils.notnil
method which returnsfalse
if ANY argument isnil
and true in all other cases- Some anti-code-inject utils
Proxy
Syntax for proxies is simple:
p = RG::Proxy.new :multiple, [[1,2,3],[4,5,6]] # :multiple mode takes array of objects with same class
p.sum # => [6, 15] # All unknown methods are redirected to stored objects
# Instance Evals and Inspects
p.p_eval "self.sum" # => [6, 15] # Proxy#p_eval calls `instance_eval` method for each object
p.p_inspect # => ["[1,2,3]","[4,5,6]"] # You see
License
The gem is available as open source under the terms of the MIT License.