{"id":14969843,"url":"https://github.com/aishek/nihilist","last_synced_at":"2025-10-26T10:31:09.645Z","repository":{"id":29131268,"uuid":"120297829","full_name":"aishek/nihilist","owner":"aishek","description":"Nigilist Ruby gem — Null Object for User model in your app","archived":false,"fork":false,"pushed_at":"2023-01-09T22:25:07.000Z","size":26,"stargazers_count":11,"open_issues_count":6,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-30T04:36:49.893Z","etag":null,"topics":["null-object-pattern","ruby","ruby-on-rails"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/nigilist","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/aishek.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2018-02-05T11:48:04.000Z","updated_at":"2024-08-24T22:52:30.000Z","dependencies_parsed_at":"2023-01-14T14:12:43.215Z","dependency_job_id":null,"html_url":"https://github.com/aishek/nihilist","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aishek%2Fnihilist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aishek%2Fnihilist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aishek%2Fnihilist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aishek%2Fnihilist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aishek","download_url":"https://codeload.github.com/aishek/nihilist/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238310305,"owners_count":19450839,"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":["null-object-pattern","ruby","ruby-on-rails"],"created_at":"2024-09-24T13:42:29.113Z","updated_at":"2025-10-26T10:31:09.333Z","avatar_url":"https://github.com/aishek.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nigilist\n\n[![Gem Version](https://badge.fury.io/rb/nigilist.svg)](https://rubygems.org/gems/nigilist)\n[![Build Status](https://travis-ci.org/aishek/nihilist.svg?branch=master)](https://travis-ci.org/aishek/nihilist)\n[![Code Climate](https://codeclimate.com/github/aishek/nihilist.svg)](https://codeclimate.com/github/aishek/nihilist)\n\n\nNigilist is extremely useful for implement Null Object pattern. It allows null object to return `false` for all question-methods, `nil` for all non-bang-methods, `[]` for all methods in plural form (and in Ruby on Rails null-relation for same name ActiveRecord model) without defining them.\n\n## Installation\n\n```bash\ngem install nigilist\n```\n\n## Usage\n\n```ruby\nclass Order \u003c ActiveRecord::Base\nend\n\nclass Guest\n  include Nigilist\n\n  def polite?\n    true\n  end\n\n  def locale\n    'ru'\n  end\nend\n\ncurrent_user = Guest.new\ncurrent_user.admin?  # false — for all question methods\ncurrent_user.polite? # true — becase it is explicit defined\ncurrent_user.orders  # Order.none — for all plural methods because same singular name ActiveRecord model exists\ncurrent_user.planets # [] — for all plural methods without because singular name ActiveRecord model doesn't exists\ncurrent_user.address # nil — for all non question, non plural and non bang methods\ncurrent_user.locale  # 'ru' — becase it is explicit defined\n```\n\n### Explanation of Null Object pattern\n\nFor example, you have a `User` model, with `#admin?` method, and `Guest` model allows you use same interface for both authorized and unauthorized users like so:\n\n```ruby\nclass Guest\n  def admin?\n    false\n  end\nend\n\ncurrent_user = current_session.user || Guest.new\ncurrent_user.admin?\n```\n\nSo when your project grows and other methods got it place inside `User` model you have to define same methods in `Guest` model which contains no logic but only return `false` or `nil`. In that case Nigilist could be helpful.\n\n## License\n\nNigilist is free software, and may be redistributed under the MIT License.\n\n## Contributors\n\n* [Alexandr Borisov](https://github.com/aishek)\n* [Ivan Nemytchenko](https://github.com/inem)\n\n## The gem about one method\n\nThe gem contains exactly one module with one method defined: `method_missing`. I'm sure you able to implement it by yourself in couple of minutes. So feel free just to copy it from `lib/nihilist.rb` 😉\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faishek%2Fnihilist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faishek%2Fnihilist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faishek%2Fnihilist/lists"}