Skip to content

Instantly share code, notes, and snippets.

@cjbottaro
Created February 1, 2012 23:22
Show Gist options
  • Save cjbottaro/1720115 to your computer and use it in GitHub Desktop.
Save cjbottaro/1720115 to your computer and use it in GitHub Desktop.
DCI with ActiveSupport callbacks
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