Created
February 1, 2012 23:22
-
-
Save cjbottaro/1720115 to your computer and use it in GitHub Desktop.
DCI with ActiveSupport callbacks
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
require "active_support" | |
module RoleA | |
def self.extended(object) | |
object.singleton_class.class_eval do | |
puts "blah" | |
puts object.inspect | |
include ActiveSupport::Callbacks | |
define_callbacks :save | |
set_callback :save, :before do | |
puts "before save" | |
end | |
end | |
end | |
def save | |
run_callbacks :save do | |
puts "#save" | |
end | |
end | |
end | |
o = Object.new | |
o.extend(RoleA) | |
o.save |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment