Charlatan
Turn any object into a proxy delegating to another object. Like that:
require 'charlatan'
class ArrayProxy
include Charlatan.new(:array)
end
array_proxy = ArrayProxy.new([])
array_proxy << 'Hello'
array_proxy << 'World'
array_proxy.size # => 2
array_proxy.join(' ') # => 'Hello World'
# always wraps responses with the proxy class
other = array_proxy + ['Oh Hai']
other.class # => ArrayProxy
Why?
I dunno, you tell me. I just like it. Which I cannot say about SimpleDelegator.
TODO: explain why
Installation
Add this line to your application's Gemfile:
gem 'charlatan'
And then execute:
$ bundle
Or install it yourself as:
$ gem install charlatan
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request