To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / vendor / plugins / awesome_nested_set / lib / awesome_nested_set / compatability.rb @ 442:753f1380d6bc

History | View | Annotate | Download (836 Bytes)

1
# Rails <2.x doesn't define #except
2
class Hash #:nodoc:
3
  # Returns a new hash without the given keys.
4
  def except(*keys)
5
    clone.except!(*keys)
6
  end unless method_defined?(:except)
7

    
8
  # Replaces the hash without the given keys.
9
  def except!(*keys)
10
    keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
11
    keys.each { |key| delete(key) }
12
    self
13
  end unless method_defined?(:except!)
14
end
15

    
16
# NamedScope is new to Rails 2.1
17
unless defined? ActiveRecord::NamedScope
18
  require 'awesome_nested_set/named_scope'
19
  ActiveRecord::Base.class_eval do
20
    include CollectiveIdea::NamedScope
21
  end
22
end
23

    
24
# Rails 1.2.x doesn't define #quoted_table_name
25
class ActiveRecord::Base  #:nodoc:
26
  def self.quoted_table_name
27
    self.connection.quote_column_name(self.table_name)
28
  end unless methods.include?('quoted_table_name')
29
end