0.0
No commit activity in last 3 years
No release in over 3 years
Enable and Disable attributes and helper methods on the model calling has_status method are added.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0

Runtime

>= 4.2.4, ~> 4.2
 Project Readme

StatifyModel¶ ↑

This project rocks and uses MIT-LICENSE.

StatifyModel provides scopes and helper methods for the models having a table column named ‘enabled` .

Installation¶ ↑

Add to your Gemfile

  • gem ‘statify_model’

Usage¶ ↑

Define a column ‘enabled’ with type ‘boolean’ in the model you wish to statify. Call the method ‘has_status` in the model.

For eg. -

class Talk < ActiveRecord::Base
  has_status
end

Scopes defined on Talk class are -

enabled - Filters all the enabled records.
  returns arel of all the enabled records.

disabled - Filters all the disabled records.
  returns arel of all the disabled records.

Instance Methods defined on Talk class are -

enable - Updates the status to be enabled.
  returns true when the status is updated succesfully in the database.
  returns false when the status is not updated in the database.

disable - Updates the status to be disabled.
  returns true when the status is updated succesfully in the database.
  returns false when the status is not updated in the database.

toggle_status - Toggles the status.
  returns true when the status is updated succesfully in the database.
  returns false when the status is not updated in the database.

enabled? - Checks whether the record is enabled.
  returns true when the status is enabled.
  returns false when the sttaus is disabled.

disabled? - Checks whether the record is disabled.
  returns true when the sttaus is disabled.
  returns false when the status is enabled.