{"id":19010354,"url":"https://github.com/railsware/chain_flow","last_synced_at":"2026-06-18T18:31:42.534Z","repository":{"id":16358750,"uuid":"19108799","full_name":"railsware/chain_flow","owner":"railsware","description":"Helps to refactor complex data processing","archived":false,"fork":false,"pushed_at":"2014-04-24T13:10:35.000Z","size":112,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":12,"default_branch":"master","last_synced_at":"2026-03-27T10:08:31.634Z","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/railsware.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":"2014-04-24T13:10:11.000Z","updated_at":"2023-07-25T13:51:37.000Z","dependencies_parsed_at":"2022-09-10T17:50:15.056Z","dependency_job_id":null,"html_url":"https://github.com/railsware/chain_flow","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/railsware/chain_flow","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/railsware%2Fchain_flow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/railsware%2Fchain_flow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/railsware%2Fchain_flow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/railsware%2Fchain_flow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/railsware","download_url":"https://codeload.github.com/railsware/chain_flow/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/railsware%2Fchain_flow/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34503507,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-18T02:00:06.871Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-08T19:10:58.167Z","updated_at":"2026-06-18T18:31:42.516Z","avatar_url":"https://github.com/railsware.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ChainFlow\n\nHelps to refactor data processing with functions composition.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem chain_flow\n\nOr install it yourself as:\n\n    $ gem install chain_flow\n\n## Usage\n\n### Interface\n\nIncluding `ChainFlow` adds two methods: `flow` and `chain`.\n`flow` accepts initial data as an argument and all the processing functions go in a block.\n\n`chain` receives initial data in a block and returns and object that can be further chained with processing functions. Call `fetch` to obtain the final result.\n\nProcessing functions should accept at least one parameter - the data. When calling these functions inside `flow` or chaining them with `chain` this first parameter should be ommitted.\n\n### Example\n\n    require 'chain_flow'\n\n    class Worker\n      include ChainFlow\n\n      def flow_process\n        flow(Array.new) do\n          add_answer\n          multiple_by(3)\n        end\n      end\n\n      def chain_process\n        chain { Array.new }.add_answer.multiple_by(3).fetch\n      end\n\n      private\n\n      # first processing function\n      def add_answer(data)\n        data \u003c\u003c 42\n      end\n\n      # second processing function\n      def multiple_by(data, count)\n        data * count\n      end\n    end\n\n    Worker.new.flow_process  #=\u003e [42, 42, 42]\n    Worker.new.chain_process #=\u003e [42, 42, 42]\n\n## How does it work?\nNotice that both `flow` and `chain` capture the caller context with closure. Calls to processing fuctions with ommitted first data parameter are intercepted with `method_missing` and called in captured caller context instead with initial data pipelined through them one-by-one.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frailsware%2Fchain_flow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frailsware%2Fchain_flow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frailsware%2Fchain_flow/lists"}