{"id":13880023,"url":"https://github.com/solnic/charlatan","last_synced_at":"2025-04-13T15:26:18.298Z","repository":{"id":10486003,"uuid":"12665605","full_name":"solnic/charlatan","owner":"solnic","description":"Neat delegation for ruby objects","archived":false,"fork":false,"pushed_at":"2014-12-15T11:14:01.000Z","size":269,"stargazers_count":69,"open_issues_count":3,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-27T06:22:32.055Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/solnic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-07T13:54:53.000Z","updated_at":"2023-12-07T23:23:32.000Z","dependencies_parsed_at":"2022-07-30T12:18:03.577Z","dependency_job_id":null,"html_url":"https://github.com/solnic/charlatan","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solnic%2Fcharlatan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solnic%2Fcharlatan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solnic%2Fcharlatan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solnic%2Fcharlatan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/solnic","download_url":"https://codeload.github.com/solnic/charlatan/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248537192,"owners_count":21120711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-06T08:02:43.962Z","updated_at":"2025-04-13T15:26:18.274Z","avatar_url":"https://github.com/solnic.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Charlatan\n\n[![Gem Version](https://badge.fury.io/rb/charlatan.png)][gem]\n[![Build Status](https://secure.travis-ci.org/solnic/charlatan.png?branch=master)][travis]\n[![Dependency Status](https://gemnasium.com/solnic/charlatan.png)][gemnasium]\n[![Code Climate](https://codeclimate.com/github/solnic/charlatan.png)][codeclimate]\n[![Coverage Status](https://coveralls.io/repos/solnic/charlatan/badge.png?branch=master)][coveralls]\n\n[gem]: https://rubygems.org/gems/charlatan\n[travis]: https://travis-ci.org/solnic/charlatan\n[gemnasium]: https://gemnasium.com/solnic/charlatan\n[codeclimate]: https://codeclimate.com/github/solnic/charlatan\n[coveralls]: https://coveralls.io/r/solnic/charlatan\n\nTurn any object into a proxy delegating to another object. Like that:\n\n``` ruby\nrequire 'charlatan'\n\nclass ArrayProxy\n  include Charlatan.new(:array)\nend\n\narray_proxy = ArrayProxy.new([])\n\narray_proxy \u003c\u003c 'Hello'\narray_proxy \u003c\u003c 'World'\n\narray_proxy.size # =\u003e 2\narray_proxy.join(' ') # =\u003e 'Hello World'\n\n# always wraps responses with the proxy class\nother = array_proxy + ['Oh Hai']\nother.class # =\u003e ArrayProxy\n```\n\nPlanned features:\n\n* optional support for equality methods\n* optional support for kind_of? and ===\n* transparent vs restricted delegation (as in, allow all calls or explicitly specify what should be delegated)\n\n## Why?\n\nThe idea is that a delegator object wrapping another object delegates method calls but it preserves the original type for return values which match the wrapped object's kind. This means if you decorate an array object and you call concat on the decorator you will get an instance of the decorator back rather than an array.\n\nOther cool aspects of this library:\n\n* You get a constructor for free which plays well with your own, just remember to call super if you override it\n* You get attr reader for the wrapped object\n* Your object correctly handles method missing and respond_to? - something that is really easy to break accidentely in an ad-hoc custom implementation\n* You don't need to inherit from any superclass, just mix it in and call it a day\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'charlatan'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install charlatan\n\n## Credits\n\n* [Dan Kubb](https://github.com/dkubb) for the original idea behind a proxy\nwrapping another object.\n* [Don Morrison](https://github.com/elskwid) for the awesome name that happened\nto be available on github and rubygems *at the same time*\n\n## Similar libraries\n\n* [casting](https://github.com/saturnflyer/casting)\n* simple_delegator in ruby stdlib\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolnic%2Fcharlatan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsolnic%2Fcharlatan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolnic%2Fcharlatan/lists"}