lib/intermodal/concerns/models/resource_linking.rb
# .replace
#  - replaces existing resources with new resource ids
#  - existing resources gets deleted
.replace
replaces existing resources with new resource ids
existing resources gets deleted
. replace replaces existing resources with new resource ids existing resources gets deleted
def replace(parent_id, resource_ids, options = {})
          transaction do
            parent = parent_model.get(parent_id, options.except(:parent, :parent_id))
            return nil unless parent
            targets = target_model.get(:all, options).where(:id => resource_ids)
            parent.send("#{target_resource_name.to_s.pluralize}=", targets)
            by_parent_id(parent_id).to_target_ids
          end
        end
def replace ( parent_id , resource_ids , options = { } ) transaction do parent = parent_model . get ( parent_id , options . except ( :parent , :parent_id ) ) return nil unless parent targets = target_model . get ( :all , options ) . where ( :id => resource_ids ) parent . send ( "#{target_resource_name.to_s.pluralize}=" , targets ) by_parent_id ( parent_id ) . to_target_ids end end
.replace
 replaces existing resources with new resource ids
 existing resources gets deleted
. replace replaces existing resources with new resource ids existing resources gets deleted
parent_id
resource_ids
options