Created
April 1, 2010 15:39
-
-
Save lucasmncastro/351956 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| module RequiredAttributes | |
| def self.included(base) | |
| base.class_eval do | |
| class << self | |
| @@required_attributes = [] | |
| def required?(attribute) | |
| @@required_attributes.include? attribute | |
| end | |
| def validates_presence_of_with_reader(*attr_names) | |
| validates_presence_of_without_reader(*attr_names) | |
| attr_names.extract_options! | |
| @@required_attributes += attr_names | |
| end | |
| alias_method_chain :validates_presence_of, :reader | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment