https://github.com/coryodaniel/within_named_scope
Determine if an activerecord instance is within a named scope.
https://github.com/coryodaniel/within_named_scope
Last synced: about 1 year ago
JSON representation
Determine if an activerecord instance is within a named scope.
- Host: GitHub
- URL: https://github.com/coryodaniel/within_named_scope
- Owner: coryodaniel
- License: mit
- Created: 2013-08-01T23:03:55.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2023-12-21T20:04:25.000Z (over 2 years ago)
- Last Synced: 2025-03-24T05:34:46.317Z (about 1 year ago)
- Language: Ruby
- Size: 121 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.markdown
- License: MIT-LICENSE
Awesome Lists containing this project
README
Within Named Scope
====================
A simple gem for drying up checking if an ActiveRecord instance is within a named scope.
Support for Rails 3.2+ and 4.0+
Usage
---------------------
Using the 'in_scope?' method:
```ruby
class Post < ActiveRecord::Base
scope :published, -> { where(published: true)}
end
Post.first.in_scope? :published
```
Adding a named method:
```ruby
class Post < ActiveRecord::Base
scope :published, -> { where(published: true)}
# Would default to published?
scope_membership :published, as: :is_published?
end
Post.first.is_published?
```
Authors
---------------------
* Cory ODaniel