Skip to content

Commit

Permalink
Deprecate after_* and before_* callback methods
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaclayton committed May 4, 2012
1 parent bef5a01 commit 0e4df80
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/factory_girl/definition_proxy.rb
@@ -1,6 +1,6 @@
module FactoryGirl
class DefinitionProxy
UNPROXIED_METHODS = %w(__send__ __id__ nil? send object_id extend instance_eval initialize block_given? raise)
UNPROXIED_METHODS = %w(__send__ __id__ nil? send object_id extend instance_eval initialize block_given? raise caller)

(instance_methods + private_instance_methods).each do |method|
undef_method(method) unless UNPROXIED_METHODS.include?(method.to_s)
Expand Down Expand Up @@ -86,6 +86,8 @@ def method_missing(name, *args, &block)
elsif args.first.respond_to?(:has_key?) && args.first.has_key?(:factory)
association(name, *args)
elsif FactoryGirl.callback_names.include?(name)
callback_when, callback_name = name.to_s.split("_", 2)
ActiveSupport::Deprecation.warn "Calling #{name} is deprecated; use the syntax #{callback_when}(:#{callback_name}) {}", caller
@definition.add_callback(Callback.new(name, block))
else
add_attribute(name, *args, &block)
Expand Down

0 comments on commit 0e4df80

Please sign in to comment.