#-- # Copyright (C) 2007 Dimitrij Denissenko # Please read LICENSE document for more information. #++ # has_and_belongs_to_many should not store duplicates when used in :uniq => true mode module ActiveRecord module Associations class AssociationCollection < AssociationProxy #:nodoc: def <<(*records) result = true load_target @owner.transaction do flatten_deeper(records).each do |record| raise_on_type_mismatch(record) unless (@reflection.options[:uniq] and @target.include?(record)) callback(:before_add, record) result &&= insert_record(record) unless @owner.new_record? @target << record callback(:after_add, record) end end end result and self end end end end # Patch for options_for_params method in actionpack/lib/action_controller/routing.rb # See http://dev.rubyonrails.org/ticket/7047 module ActionController module Routing class RouteSet def options_as_params(options) options_as_params = options[:controller] ? { :action => "index" } : {} options.each do |k, value| options_as_params[k] = (value.is_a?(Array) && k.to_s != 'path') ? value : value.to_param end options_as_params end end end end module ActiveRecord module ConnectionAdapters #:nodoc: class SQLiteAdapter < AbstractAdapter protected def table_structure_with_field_cleaning(table_name) table_structure_without_field_cleaning(table_name).map do |field| field.each_pair do |k,v| field[k] = (v == 'NULL' ? nil : v.gsub(%r{^'(.*)'$}, '\1')) if v.is_a?(String) end field end end alias_method_chain :table_structure, :field_cleaning end end end if ENABLE_SUBVERSION module Svn @@dirty_runs = 0 def self.sweep_garbage! GC.start if (@@dirty_runs = (@@dirty_runs + 1) % 10).zero? end module Core class Stream def close_with_manual_garbage_collection close_without_manual_garbage_collection Svn.sweep_garbage! end alias_method_chain :close, :manual_garbage_collection end end module Fs class Root def copied_from_with_manual_garbage_collection(*args) Svn.sweep_garbage! copied_from_without_manual_garbage_collection(*args) end alias_method_chain :copied_from, :manual_garbage_collection end end end end