{"id":15593417,"url":"https://github.com/laertispappas/monadix","last_synced_at":"2025-04-05T06:25:54.356Z","repository":{"id":93703042,"uuid":"603504090","full_name":"laertispappas/monadix","owner":"laertispappas","description":"Simple Result object in ruby","archived":false,"fork":false,"pushed_at":"2023-02-18T18:23:37.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-10T14:13:51.089Z","etag":null,"topics":["ruby","ruby-gem"],"latest_commit_sha":null,"homepage":"https://github.com/laertispappas/monadix","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/laertispappas.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-18T18:01:02.000Z","updated_at":"2023-02-18T18:37:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"7f2ceca8-d967-4210-8116-3f1ca2a31787","html_url":"https://github.com/laertispappas/monadix","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"aa1b7c05594c6835c47d65c65d0ae758cb086987"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laertispappas%2Fmonadix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laertispappas%2Fmonadix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laertispappas%2Fmonadix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laertispappas%2Fmonadix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/laertispappas","download_url":"https://codeload.github.com/laertispappas/monadix/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247297205,"owners_count":20915793,"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":["ruby","ruby-gem"],"created_at":"2024-10-03T00:17:44.332Z","updated_at":"2025-04-05T06:25:54.334Z","avatar_url":"https://github.com/laertispappas.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Monadix\n\nSimple result objects in Ruby.\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n    $ bundle add monadix\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n\n    $ gem install monadix\n\n## Usage\n\n```ruby\n# file app/lib\n\n# It's a good practice to not expose inner gems to the rest of the app\n# so we wrap it.\nmodule Result\n  class Success \u003c Monadix::Success; end\n  class Failure \u003c Monadix::Success; end\nend\n\nclass SomeService\n  G_OAUTH = lambda do |cmd|\n    payload = Google::Auth::IDTokens.verify_oidc(cmd.jwt, aud: ENV.fetch(\"GOOGLE_OAUTH_CLIENT_ID\"))\n    info =  UserInfo.new(email: payload[:email], name: payload[:name])\n    Result::Success.new(info)\n  end\n\n  CreateUser = lambda do |res|\n    res.then do |info|\n      user = UserFactory.create(info)\n      user.save \u0026\u0026 Result::Success.new(LoginToken.new(user)) || \n        Result::Failure.new(\"User cannot be created\", user.errors.full_messages)\n    end\n  end\n  \n  def call(cmd)\n    steps.reduce(cmd) { |memo, step| step.call(memo) }\n  end\n  \n  private\n  \n  def steps\n    [\n      G_AUTH,\n      CreateUser\n    ]\n  end\nend\n\n# Some controller\n\nclass AuthCallbacksControler\n  def google_oauth2\n    cmd = GoogleSignInCommand.new(jwt: params.require(:credential))\n    res = SomeService.new.call(cmd)\n    if res.success?\n      render json: res.data\n    else\n      render json: res.data, status: :bad_request\n    end\n  end\nend\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/monadix. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/monadix/blob/master/CODE_OF_CONDUCT.md).\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 Monadix project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/monadix/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaertispappas%2Fmonadix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaertispappas%2Fmonadix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaertispappas%2Fmonadix/lists"}