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
module ObjectDiagnostics | |
extend self | |
#This is handy when you want to determine what types of objects are contributing to memory bloat | |
#returns the change in object counts since the last time this method was called | |
def change_in_object_counts | |
#this will start all counts at 0 for the initial run | |
@previous_counts ||= Hash.new(0) |
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
module ActiveRecord::Validations::ClassMethods | |
#inspired by rails-schema_validations | |
#https://github.com/gregwebs/rails-schema-validations | |
def add_generic_validations | |
begin | |
self.columns.map do |column| | |
case column.type | |
when :date | |
validates_format_of_date(column.name) #this is a custom validation we defined (not part of rails) | |
end |