{"id":15046929,"url":"https://github.com/michinaoshimizu/edrive","last_synced_at":"2026-02-06T15:35:29.008Z","repository":{"id":62557772,"uuid":"139300301","full_name":"MichinaoShimizu/edrive","owner":"MichinaoShimizu","description":"Generic event dispatcher for ruby","archived":false,"fork":false,"pushed_at":"2019-12-06T14:36:20.000Z","size":30,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-05T15:12:40.433Z","etag":null,"topics":["event-dispatcher","gem","rspec","ruby","ruby-gems"],"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/MichinaoShimizu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-01T04:30:36.000Z","updated_at":"2019-12-06T14:36:22.000Z","dependencies_parsed_at":"2022-11-03T06:45:21.513Z","dependency_job_id":null,"html_url":"https://github.com/MichinaoShimizu/edrive","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MichinaoShimizu%2Fedrive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MichinaoShimizu%2Fedrive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MichinaoShimizu%2Fedrive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MichinaoShimizu%2Fedrive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MichinaoShimizu","download_url":"https://codeload.github.com/MichinaoShimizu/edrive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242048577,"owners_count":20063404,"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":["event-dispatcher","gem","rspec","ruby","ruby-gems"],"created_at":"2024-09-24T20:53:45.955Z","updated_at":"2026-02-06T15:35:28.979Z","avatar_url":"https://github.com/MichinaoShimizu.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# edrive\n\n[![Gem Version](https://badge.fury.io/rb/edrive.svg)](https://badge.fury.io/rb/edrive)\n\nProvide simple event dispatcher mechanism for all of ruby products.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'edrive'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install edrive\n\n## Usage\n\n### Edrive::Dispatcher\n\nmain class\n\n#### lambda \u0026 dispatch\n\n```ruby\ndispatcher = Edrive::Dispatcher.new\ndispatcher.subscribe(:event, -\u003e { puts 1 })\ndispatcher.subscribe(:event, -\u003e { puts 2 })\ndispatcher.subscribe(:event, -\u003e { puts 3 })\ndispatcher.dispatch(:event)\n\n1\n2\n3\n```\n\n#### lambda \u0026 dispatch with data\n\n```ruby\ndispatcher = Edrive::Dispatcher.new\ndispatcher.subscribe(:event, -\u003e(data) { data + 1 })\ndispatcher.subscribe(:event, -\u003e(data) { data + 2 })\ndispatcher.subscribe(:event, -\u003e(data) { data + 3 })\ndispatcher.subscribe(:event, -\u003e(data) { puts data })\ndispatcher.dispatch_with_data(:event, 100)\n\n106\n```\n\n#### block\n\n```ruby\ndispatcher = Edrive::Dispatcher.new\ndispatcher.subscribe(:event) { puts 1 }\ndispatcher.subscribe(:event) { puts 2 }\ndispatcher.subscribe(:event) { puts 3 }\ndispatcher.dispatch(:event)\n\n1\n2\n3\n```\n\n#### block \u0026 dispatch with data\n\n```ruby\ndispatcher = Edrive::Dispatcher.new\ndispatcher.subscribe(:event) { |data| data + 1 }\ndispatcher.subscribe(:event) { |data| data + 2 }\ndispatcher.subscribe(:event) { |data| data + 3 }\ndispatcher.dispatch_with_data(:event, 100)\n\n106\n```\n\n### clear target event\n\n```ruby\ndispatcher.clear!(:event)\n```\n\n### clear all event\n\n```ruby\ndispatcher.clear_all!\n```\n\n### Edrive::ProcessorDispatcher\n\nEvent dispatcher for processor class inherited `Edrive::Dispatcher`.\n\nUse `:before_process`, `:after_process` events only in this class.\n\nThis class has `dispatch_all` method.\n\n```ruby\n  def dispatch_all(use_result = true)\n    dispatch(DEFINED_EVENT[0])\n    if use_result\n      result = dispatch_processor_process\n      return dispatch_with_data(DEFINED_EVENT[1], result)\n    end\n    dispatch_processor_process\n    dispatch(DEFINED_EVENT[1])\n  end\n```\n\n### Edrive::Handler\n\nsample event handlers class.\n\n```ruuby\nrequire 'edrive'\n\ndispatcher = Edrive::Dispatcher.new\ndispatcher.subscribe(:before, Edrive::Handler.hash2json)\ndispatcher.subscribe(:before, Edrive::Handler.json2hash)\nputs dispatcher.dispatch_with_data(:before, hoge: 2, fuga: 3)\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/MichinaoShimizu/edrive. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Edrive project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/MichinaoShimizu/edrive/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichinaoshimizu%2Fedrive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichinaoshimizu%2Fedrive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichinaoshimizu%2Fedrive/lists"}