Sha256: dd1e64eeea0f25894cc0010a109b9979d3b2c6b91dd122ae9475d97a3fa6d827
Contents?: true
Size: 930 Bytes
Versions: 12
Compression:
Stored size: 930 Bytes
Contents
module ActiveType module ChangeAssociation extend ActiveSupport::Concern module ClassMethods def change_association(association_name, new_scope, new_options = nil) if (existing_association = self.reflect_on_association(association_name)) if new_scope.is_a?(Hash) new_options = new_scope new_scope = nil end original_options = existing_association.options if ActiveRecord::VERSION::MAJOR > 3 new_scope ||= existing_association.scope public_send(existing_association.macro, association_name, new_scope, **original_options.merge(new_options)) else public_send(existing_association.macro, association_name, **original_options.merge(new_options)) end else raise ArgumentError, "unrecognized association `#{association_name}`" end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems