Created
November 2, 2014 00:36
-
-
Save sixty4bit/8d4f6d7f45008f74cf20 to your computer and use it in GitHub Desktop.
Active Record with state.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ active: 'activate!', inactive: 'deactivate!', blocked: 'block!', suggested: 'suggest!' }.each do |state_name, trigger_name| | |
define_singleton_method(state_name) { where(state: state_name.to_s) } | |
define_method(trigger_name.to_sym) { update_attribute(state: state_name.to_s) } | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm going to go with sexy!