{"id":22144970,"url":"https://github.com/jim/interrogation","last_synced_at":"2025-06-28T20:09:14.836Z","repository":{"id":532267,"uuid":"161331","full_name":"jim/interrogation","owner":"jim","description":"ActiveRecord hack to create boolean accessors from named_scope definitions","archived":false,"fork":false,"pushed_at":"2009-06-05T05:40:25.000Z","size":88,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-28T20:09:12.803Z","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/jim.png","metadata":{"files":{"readme":"README.rdoc","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-03-27T22:05:09.000Z","updated_at":"2019-08-13T14:12:57.000Z","dependencies_parsed_at":"2022-07-07T15:21:13.662Z","dependency_job_id":null,"html_url":"https://github.com/jim/interrogation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jim/interrogation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim%2Finterrogation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim%2Finterrogation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim%2Finterrogation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim%2Finterrogation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jim","download_url":"https://codeload.github.com/jim/interrogation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim%2Finterrogation/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262490403,"owners_count":23319285,"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":[],"created_at":"2024-12-01T22:36:46.398Z","updated_at":"2025-06-28T20:09:14.815Z","avatar_url":"https://github.com/jim.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Interrogation\n\nThis is a little hack I came up with today when I got tired of duplicating logic in scopes and accessor methods. If I define a method in a model like this:\n\n  class Submarine \u003c ActiveRecord::Base\n    named_scope :on_surface, :conditions =\u003e {:location =\u003e 'surface'}\n    named_scope :submerged, :conditions =\u003e {:location =\u003e 'under water'}\n  end\n\nI should be able to interrogate the model like this without needing to define Submarine#on_surface? or Submarine#submerged?:\n\n  sub = Submarine.first =\u003e #\u003cSubmarine id: 1, location: 'surface'\u003e\n  sub.on_surface? =\u003e true\n  sub.submerged? =\u003e false\n\n== How this works\n\nThis version contains a preliminary attempt at parsing simple conditions against a model's attributes, with a fallback to the database for complicated conditions. Which means that some methods will hit your database on each call. Something to be aware of.\n\n== WARNING\n\nThe big problem here is that an object's state is not always in sync with the database. I've thought about this a lot, and at this point I think it's best to raise an exception when using these methods on dirty objects. I think handling dirty objects is beyond the scope of this little hack.\n\nCopyright (c) 2009 Jim Benton, released under the MIT license","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjim%2Finterrogation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjim%2Finterrogation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjim%2Finterrogation/lists"}