{"id":25619333,"url":"https://github.com/hunterae/call_with_params","last_synced_at":"2025-10-07T01:55:49.193Z","repository":{"id":59151793,"uuid":"12392772","full_name":"hunterae/call_with_params","owner":"hunterae","description":"Call a Proc with an arbitrary number of params","archived":false,"fork":false,"pushed_at":"2013-11-04T18:40:46.000Z","size":140,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-01T19:45:57.392Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hunterae.png","metadata":{"files":{"readme":"README.rdoc","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-08-27T00:16:02.000Z","updated_at":"2013-11-04T18:40:49.000Z","dependencies_parsed_at":"2022-09-15T22:02:21.714Z","dependency_job_id":null,"html_url":"https://github.com/hunterae/call_with_params","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/hunterae/call_with_params","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hunterae%2Fcall_with_params","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hunterae%2Fcall_with_params/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hunterae%2Fcall_with_params/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hunterae%2Fcall_with_params/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hunterae","download_url":"https://codeload.github.com/hunterae/call_with_params/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hunterae%2Fcall_with_params/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278708028,"owners_count":26031932,"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","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"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":"2025-02-22T06:16:56.964Z","updated_at":"2025-10-07T01:55:49.171Z","avatar_url":"https://github.com/hunterae.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= call_with_params\n\nCall a Proc with an arbitrary number of params. The Proc will only be passed the number of arguments that it takes. If a Proc is not passed in as an argument, the first argument will simply be returned.\n\n== Installation\nAdd the following to your Gemfile:\n  gem 'call_with_params'\n\nCallWithParams can be mixed into any class by adding a line:\n  include CallWithParams\n\nIt is likely you will want to include CallWithParams in your views. This can best be accomplished by adding in an initializer:\n  ActionView::Base.send :include, CallWithParams\n\n== Sample Usage\nThe best place to demonstrate the usage for CallWithParams is in the view:\n  link_to \"My URL\", call_with_params(my_url, user)\n\nIf \"my_url\" is not a Proc, the link will simply be the specified \"my_url\" param. However, if it is a Proc, it will call that Proc with any additional params passed into the call_with_params method.\n\nSuppose, for example, that my_url is a locally defined Proc, such as:\n  \u003c% my_url = Proc.new {|user| admin_user_path(user) } %\u003e\n  \u003c%= link_to \"My URL\", call_with_params(my_url, user) %\u003e\n\nThe Proc can also choose to not take all the parameters that are passed in:\n  \u003c% my_url = Proc.new {|user, order_field| admin_user_path(user, :order =\u003e order_field) } %\u003e\n  \u003c%= link_to \"My URL\", call_with_params(my_url, user, \"name\", 1, 2, 3, 4, 5) %\u003e\n\nNotice the Proc only takes the first two arguments that are passed in.\n\n\nAdditionally, there is another method in CallWithParams called call_each_hash_value_with_params which can take hash of Procs, and invoke each Procs with the additional params passed into the call_each_hash_value_with_params method.\n\nFor example:\n  \u003c%= content_tag :tr, call_each_hash_value_with_params({:id =\u003e Proc.new {|user| \"user-#{user.id}\"}, \n                                                         :class =\u003e Proc.new { cycle(\"even\", \"odd\") }}, user) %\u003e\n\nAny hash values that are not Procs will not be evaluated as Procs:\n  \u003c%= content_tag :tr, call_each_hash_value_with_params({:id =\u003e Proc.new {|user| \"user-#{user.id}\"},\n                                                         :class =\u003e Proc.new { cycle(\"even\", \"odd\") },\n                                                         :style =\u003e \"color: red\" }, user) %\u003e\n\n== Contributing to call_with_params\n \n* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.\n* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.\n* Fork the project.\n* Start a feature/bugfix branch.\n* Commit and push until you are happy with your contribution.\n* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.\n* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.\n\n== Copyright\n\nCopyright (c) 2013 Andrew Hunter. See LICENSE.txt for\nfurther details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhunterae%2Fcall_with_params","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhunterae%2Fcall_with_params","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhunterae%2Fcall_with_params/lists"}