diff options
author | Jon Leighton <j@jonathanleighton.com> | 2012-08-10 16:38:51 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2012-08-10 17:45:07 +0100 |
commit | 6bb8afb45e0fd9243a487e12a0988ac6ea9916bc (patch) | |
tree | 2310fea1d758bf62840145eab9f7b46c3f7e52a3 /activerecord/lib/active_record/associations/builder/belongs_to.rb | |
parent | 825c05d491205840438d3ec346bd3c12e5291a93 (diff) | |
download | rails-6bb8afb45e0fd9243a487e12a0988ac6ea9916bc.tar.gz rails-6bb8afb45e0fd9243a487e12a0988ac6ea9916bc.tar.bz2 rails-6bb8afb45e0fd9243a487e12a0988ac6ea9916bc.zip |
DRY up handling of dependent option
Diffstat (limited to 'activerecord/lib/active_record/associations/builder/belongs_to.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/builder/belongs_to.rb | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/activerecord/lib/active_record/associations/builder/belongs_to.rb b/activerecord/lib/active_record/associations/builder/belongs_to.rb index bac21574c7..acfc3073a9 100644 --- a/activerecord/lib/active_record/associations/builder/belongs_to.rb +++ b/activerecord/lib/active_record/associations/builder/belongs_to.rb @@ -1,4 +1,3 @@ - module ActiveRecord::Associations::Builder class BelongsTo < SingularAssociation #:nodoc: def macro @@ -17,7 +16,6 @@ module ActiveRecord::Associations::Builder reflection = super add_counter_cache_callbacks(reflection) if options[:counter_cache] add_touch_callbacks(reflection) if options[:touch] - configure_dependency reflection end @@ -68,22 +66,8 @@ module ActiveRecord::Associations::Builder model.after_destroy(method_name) end - def configure_dependency - if dependent = options[:dependent] - validate_dependent_option [:destroy, :delete] - - model.send(:class_eval, <<-eoruby, __FILE__, __LINE__ + 1) - def #{dependency_method_name} - association(:#{name}).handle_dependency - end - eoruby - - model.after_destroy dependency_method_name - end - end - - def dependency_method_name - "belongs_to_dependent_for_#{name}" + def valid_dependent_options + [:destroy, :delete] end end end |