Skip to content

Instantly share code, notes, and snippets.

@joshuaclayton
Created November 30, 2010 18:04
Show Gist options
  • Save joshuaclayton/722088 to your computer and use it in GitHub Desktop.
Save joshuaclayton/722088 to your computer and use it in GitHub Desktop.
module Archives
module Callbacks
def self.included(base)
base.send :include, Archives::Callbacks::InstanceMethods
base.before_create :do_something_awesome
end
module InstanceMethods
private
def do_something_awesome
true
end
end
end
module Validations
def self.included(base)
base.send :include, Archives::Validations::InstanceMethods
base.validate :something_is_correct
end
module InstanceMethods
private
def something_is_correct
unless something.correct?
errors.add(:something, "is SO not right")
end
end
end
end
end
class Archive < ActiveRecord::Base
include Archives::Callbacks
include Archives::Validations
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment