{"id":23869485,"url":"https://github.com/fredwu/ruby_decorators","last_synced_at":"2025-06-14T16:06:05.351Z","repository":{"id":4623038,"uuid":"5767068","full_name":"fredwu/ruby_decorators","owner":"fredwu","description":"Ruby method decorators inspired by Python.","archived":false,"fork":false,"pushed_at":"2013-11-09T07:23:10.000Z","size":135,"stargazers_count":63,"open_issues_count":0,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T05:06:15.678Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fredwu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-09-11T16:27:52.000Z","updated_at":"2020-09-30T16:57:39.000Z","dependencies_parsed_at":"2022-09-25T01:52:22.077Z","dependency_job_id":null,"html_url":"https://github.com/fredwu/ruby_decorators","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/fredwu/ruby_decorators","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredwu%2Fruby_decorators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredwu%2Fruby_decorators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredwu%2Fruby_decorators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredwu%2Fruby_decorators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fredwu","download_url":"https://codeload.github.com/fredwu/ruby_decorators/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredwu%2Fruby_decorators/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259843330,"owners_count":22920312,"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":"2025-01-03T12:35:45.280Z","updated_at":"2025-06-14T16:06:05.328Z","avatar_url":"https://github.com/fredwu.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ruby Decorators\n\n#### Ruby method decorators inspired by Python.\n\nI wrote this as a small practice for some ruby meta-programming fun. The implementation is relatively simple, and is thread safe.\n\nThere are also these other two implementations:\n\n- Yehuda Katz's [Ruby Decorators](https://github.com/wycats/ruby_decorators)\n- Michael Fairley's [Method Decorators](https://github.com/michaelfairley/method_decorators)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'ruby_decorators'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install ruby_decorators\n\n## Usage\n\n```ruby\nclass Hi \u003c RubyDecorator\n  def call(this, *args, \u0026blk)\n    this.call(*args, \u0026blk).sub('hello', 'hi')\n  end\nend\n\nclass Batman \u003c RubyDecorator\n  def call(this, *args, \u0026blk)\n    this.call(*args, \u0026blk).sub('world', 'batman')\n  end\nend\n\nclass Catwoman \u003c RubyDecorator\n  def initialize(*args)\n    @args = args.any? ? args : ['catwoman']\n  end\n\n  def call(this, *args, \u0026blk)\n    this.call(*args, \u0026blk).sub('world', @args.join(' '))\n  end\nend\n\nclass World\n  extend RubyDecorators\n\n  def initialize\n    @greeting = 'hello world'\n  end\n\n  def hello_world\n    @greeting\n  end\n\n  +Batman\n  def hello_batman\n    @greeting\n  end\n\n  +Hi\n  +Catwoman\n  def hello_catwoman\n    @greeting\n  end\n\n  +Catwoman.new('super', 'catwoman')\n  def hello_super_catwoman\n    @greeting\n  end\nend\n\nworld = World.new\n\nworld.hello_world          # =\u003e \"hello world\"\nworld.hello_batman         # =\u003e \"hello batman\"\nworld.hello_catwoman       # =\u003e \"hi catwoman\"\nworld.hello_super_catwoman # =\u003e \"hello super catwoman\"\n```\n\n## License\n\nCopyright (c) 2012 [Fred Wu](http://fredwu.me/)\n\nLicensed under the [MIT license](http://fredwu.mit-license.org/).\n\n\n[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/fredwu/ruby_decorators/trend.png)](https://bitdeli.com/free \"Bitdeli Badge\")\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffredwu%2Fruby_decorators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffredwu%2Fruby_decorators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffredwu%2Fruby_decorators/lists"}