Sha256: 354677fbdbabd477955f3238845fb69e959cee42835a4e7df266cadaf475be5a
Contents?: true
Size: 1.61 KB
Versions: 1
Compression:
Stored size: 1.61 KB
Contents
# Jacaranda Generates helper methods based on your model validations creating common methods and scopes. ## Installation Add this line to your application's Gemfile: gem 'jacaranda' And then execute: $ bundle Or install it yourself as: $ gem install jacaranda ## Usage ### Basic Simply add the following line **after the validations**: acts_as_jacaranda like that class Post < ActiveRecord::Base validates :status, inclusion: { in: %w{published unpublished draft} } acts_as_jacaranda end Now your model Post received some powers, we see them. #### Predicate methods Ask `@post` if it was published with `@post.published?` or it is a draft with `@post.draft?`. #### Scopes Find the posts based on column `status` using the generated scopes like `Post.published` e `Post.draft`. ### Scoped Perhaps model has 2 validations of inclusion that have valid values repeated class Post < ActiveRecord::Base validates :status, inclusion: { in: %w{published unpublished draft} } validates :kind, inclusion: { in: %w{report unpublished draft} } acts_as_jacaranda end in this case use Jacaranda with the param `scoped`: acts_as_jacaranda scoped: true which will generate methods based on column like `#unpublished_status?` and `#unpublished_kind?`. ## Versioning Jacaranda follow the [Semantic Versioning](http://semver.org/). ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Added some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jacaranda-0.0.1 | README.md |