active_record.rb 3.5 KB
Newer Older
D
Initial  
David Heinemeier Hansson 已提交
1
#--
2
# Copyright (c) 2004-2010 David Heinemeier Hansson
D
Initial  
David Heinemeier Hansson 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#++

24

25 26 27 28 29
activesupport_path = File.expand_path('../../../activesupport/lib', __FILE__)
$:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.include?(activesupport_path)

activemodel_path = File.expand_path('../../../activemodel/lib', __FILE__)
$:.unshift(activemodel_path) if File.directory?(activemodel_path) && !$:.include?(activemodel_path)
30

31
require 'active_support'
X
Xavier Noria 已提交
32
require 'active_support/i18n'
33
require 'active_model'
34
require 'arel'
J
Jeremy Kemper 已提交
35

J
Joshua Peek 已提交
36
module ActiveRecord
C
Carlhuda 已提交
37
  extend ActiveSupport::Autoload
D
Initial  
David Heinemeier Hansson 已提交
38

J
Joshua Peek 已提交
39 40 41
  eager_autoload do
    autoload :VERSION

42 43
    autoload :ActiveRecordError, 'active_record/errors'
    autoload :ConnectionNotEstablished, 'active_record/errors'
J
Joshua Peek 已提交
44 45 46 47 48 49

    autoload :Aggregations
    autoload :AssociationPreload
    autoload :Associations
    autoload :AttributeMethods
    autoload :AutosaveAssociation
50

J
Joshua Peek 已提交
51
    autoload :Relation
52 53 54 55

    autoload_under 'relation' do
      autoload :QueryMethods
      autoload :FinderMethods
56
      autoload :Calculations
57
      autoload :PredicateBuilder
58
      autoload :SpawnMethods
P
Pratik Naik 已提交
59
      autoload :Batches
60 61
    end

J
Joshua Peek 已提交
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
    autoload :Base
    autoload :Callbacks
    autoload :DynamicFinderMatch
    autoload :DynamicScopeMatch
    autoload :Migration
    autoload :Migrator, 'active_record/migration'
    autoload :NamedScope
    autoload :NestedAttributes
    autoload :Observer
    autoload :QueryCache
    autoload :Reflection
    autoload :Schema
    autoload :SchemaDumper
    autoload :Serialization
    autoload :SessionStore
    autoload :Timestamp
    autoload :Transactions
    autoload :Validations
  end
D
Initial  
David Heinemeier Hansson 已提交
81

J
Joshua Peek 已提交
82
  module AttributeMethods
C
Carlhuda 已提交
83 84
    extend ActiveSupport::Autoload

J
Joshua Peek 已提交
85 86 87 88 89 90 91 92 93
    eager_autoload do
      autoload :BeforeTypeCast
      autoload :Dirty
      autoload :PrimaryKey
      autoload :Query
      autoload :Read
      autoload :TimeZoneConversion
      autoload :Write
    end
J
Joshua Peek 已提交
94 95
  end

J
Joshua Peek 已提交
96
  module Locking
C
Carlhuda 已提交
97
    extend ActiveSupport::Autoload
98

J
Joshua Peek 已提交
99 100 101 102
    eager_autoload do
      autoload :Optimistic
      autoload :Pessimistic
    end
J
Joshua Peek 已提交
103
  end
104

J
Joshua Peek 已提交
105
  module ConnectionAdapters
C
Carlhuda 已提交
106
    extend ActiveSupport::Autoload
107

J
Joshua Peek 已提交
108 109
    eager_autoload do
      autoload :AbstractAdapter
110
      autoload :ConnectionManagement, "active_record/connection_adapters/abstract/connection_pool"
J
Joshua Peek 已提交
111
    end
J
Joshua Peek 已提交
112
  end
J
Joshua Peek 已提交
113 114 115

  autoload :TestCase
  autoload :TestFixtures, 'active_record/fixtures'
116
end
117

118 119
ActiveSupport.on_load(:active_record) do
  Arel::Table.engine = Arel::Sql::Engine.new(self)
J
Joshua Peek 已提交
120
end
S
Sven Fuchs 已提交
121

122
I18n.load_path << File.dirname(__FILE__) + '/active_record/locale/en.yml'