Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

we can define callbacks without a builder instance

  • Loading branch information...
commit b86a4965b8532286430b7cd9b359a2574d745b92 1 parent 73ee85f
@tenderlove tenderlove authored
View
6 activerecord/lib/active_record/associations/builder/association.rb
@@ -32,7 +32,7 @@ def self.build(model, name, scope, options, &block)
builder = new(name, scope, options, &block)
reflection = builder.build(model)
builder.define_accessors model, reflection
- builder.define_callbacks model, reflection
+ define_callbacks model, reflection
builder.define_extensions model
reflection
end
@@ -68,8 +68,8 @@ def validate_options
def define_extensions(model)
end
- def define_callbacks(model, reflection)
- self.class.add_before_destroy_callbacks(model, reflection) if reflection.options[:dependent]
+ def self.define_callbacks(model, reflection)
+ add_before_destroy_callbacks(model, reflection) if reflection.options[:dependent]
Association.extensions.each do |extension|
extension.build model, reflection
end
View
6 activerecord/lib/active_record/associations/builder/belongs_to.rb
@@ -12,10 +12,10 @@ def self.valid_dependent_options
[:destroy, :delete]
end
- def define_callbacks(model, reflection)
+ def self.define_callbacks(model, reflection)
super
- self.class.add_counter_cache_callbacks(model, reflection) if reflection.options[:counter_cache]
- self.class.add_touch_callbacks(model, reflection) if reflection.options[:touch]
+ add_counter_cache_callbacks(model, reflection) if reflection.options[:counter_cache]
+ add_touch_callbacks(model, reflection) if reflection.options[:touch]
end
def define_accessors(mixin, reflection)
View
4 activerecord/lib/active_record/associations/builder/collection_association.rb
@@ -23,12 +23,12 @@ def initialize(name, scope, options)
end
end
- def define_callbacks(model, reflection)
+ def self.define_callbacks(model, reflection)
super
name = reflection.name
options = reflection.options
CALLBACKS.each { |callback_name|
- self.class.define_callback(model, callback_name, name, options)
+ define_callback(model, callback_name, name, options)
}
end
View
2  activerecord/lib/active_record/associations/builder/has_and_belongs_to_many.rb
@@ -8,7 +8,7 @@ def valid_options
super + [:join_table, :association_foreign_key]
end
- def define_callbacks(model, reflection)
+ def self.define_callbacks(model, reflection)
super
name = reflection.name
model.send(:include, Module.new {
Please sign in to comment.
Something went wrong with that request. Please try again.