Sha256: 7c4b1219771b681424e167d07bd87b79fc5419cd9e49efa23918b0672bad12e7
Contents?: true
Size: 1.05 KB
Versions: 2
Compression:
Stored size: 1.05 KB
Contents
# Rails Scopes A gem that wraps up some meta programmed scopes generators. This gem is an attempt to put together useful code generation for active records common scopes. Note: For now, as it is a POC, it is just working with scopes combiner that aims to create scopes based on hashs, like, status for a state machine. ## Installation Add this line to your application's Gemfile: gem 'rails_scopes' And then execute: $ bundle Or install it yourself as: $ gem install rails_scopes ## Usage As it relies on metaprogramming you just need to extend your active record ### Example code ```ruby class Example < ActiveRecord::Base extend RailsScopes::ScopesCombiner enum status: { active: 22, inactive: 14, running: 32, stuck: 42, waiting: 465, dunno: 4880 } combine_scopes_for_attribute :status, statuses end ``` ## Contributing to Rails Scopes * Pull requests with unit tests or specs and a version branch are welcomed. * Fork the project. * Start a feature/bugfix branch. * Commit and push as much as you want. * Make sure to add tests for it.
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rails_scopes-0.0.3 | README.md |
rails_scopes-0.0.2 | README.md |