activerecord 3.2.22.4 → 4.0.13
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2799 -617
- data/MIT-LICENSE +1 -1
- data/README.rdoc +23 -32
- data/examples/performance.rb +1 -1
- data/lib/active_record/aggregations.rb +40 -34
- data/lib/active_record/association_relation.rb +22 -0
- data/lib/active_record/associations/alias_tracker.rb +4 -2
- data/lib/active_record/associations/association.rb +60 -46
- data/lib/active_record/associations/association_scope.rb +46 -40
- data/lib/active_record/associations/belongs_to_association.rb +17 -4
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +1 -1
- data/lib/active_record/associations/builder/association.rb +81 -28
- data/lib/active_record/associations/builder/belongs_to.rb +73 -56
- data/lib/active_record/associations/builder/collection_association.rb +54 -40
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +23 -41
- data/lib/active_record/associations/builder/has_many.rb +8 -64
- data/lib/active_record/associations/builder/has_one.rb +13 -50
- data/lib/active_record/associations/builder/singular_association.rb +13 -13
- data/lib/active_record/associations/collection_association.rb +130 -96
- data/lib/active_record/associations/collection_proxy.rb +916 -63
- data/lib/active_record/associations/has_and_belongs_to_many_association.rb +15 -13
- data/lib/active_record/associations/has_many_association.rb +35 -8
- data/lib/active_record/associations/has_many_through_association.rb +37 -17
- data/lib/active_record/associations/has_one_association.rb +42 -19
- data/lib/active_record/associations/has_one_through_association.rb +1 -1
- data/lib/active_record/associations/join_dependency/join_association.rb +39 -22
- data/lib/active_record/associations/join_dependency/join_base.rb +2 -2
- data/lib/active_record/associations/join_dependency/join_part.rb +21 -8
- data/lib/active_record/associations/join_dependency.rb +30 -9
- data/lib/active_record/associations/join_helper.rb +1 -11
- data/lib/active_record/associations/preloader/association.rb +29 -33
- data/lib/active_record/associations/preloader/collection_association.rb +1 -1
- data/lib/active_record/associations/preloader/has_and_belongs_to_many.rb +2 -2
- data/lib/active_record/associations/preloader/has_many_through.rb +6 -2
- data/lib/active_record/associations/preloader/has_one.rb +1 -1
- data/lib/active_record/associations/preloader/through_association.rb +13 -17
- data/lib/active_record/associations/preloader.rb +20 -43
- data/lib/active_record/associations/singular_association.rb +11 -11
- data/lib/active_record/associations/through_association.rb +3 -3
- data/lib/active_record/associations.rb +223 -282
- data/lib/active_record/attribute_assignment.rb +134 -154
- data/lib/active_record/attribute_methods/before_type_cast.rb +44 -5
- data/lib/active_record/attribute_methods/dirty.rb +36 -29
- data/lib/active_record/attribute_methods/primary_key.rb +45 -31
- data/lib/active_record/attribute_methods/query.rb +5 -4
- data/lib/active_record/attribute_methods/read.rb +67 -90
- data/lib/active_record/attribute_methods/serialization.rb +133 -70
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +51 -45
- data/lib/active_record/attribute_methods/write.rb +34 -39
- data/lib/active_record/attribute_methods.rb +268 -108
- data/lib/active_record/autosave_association.rb +80 -73
- data/lib/active_record/base.rb +54 -451
- data/lib/active_record/callbacks.rb +60 -22
- data/lib/active_record/coders/yaml_column.rb +18 -21
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +347 -197
- data/lib/active_record/connection_adapters/abstract/database_limits.rb +9 -0
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +146 -138
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +25 -19
- data/lib/active_record/connection_adapters/abstract/quoting.rb +19 -3
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +151 -142
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +70 -0
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +499 -217
- data/lib/active_record/connection_adapters/abstract/transaction.rb +208 -0
- data/lib/active_record/connection_adapters/abstract_adapter.rb +209 -44
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +169 -61
- data/lib/active_record/connection_adapters/column.rb +67 -36
- data/lib/active_record/connection_adapters/connection_specification.rb +96 -0
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +28 -29
- data/lib/active_record/connection_adapters/mysql_adapter.rb +200 -73
- data/lib/active_record/connection_adapters/postgresql/array_parser.rb +98 -0
- data/lib/active_record/connection_adapters/postgresql/cast.rb +160 -0
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +240 -0
- data/lib/active_record/connection_adapters/postgresql/oid.rb +374 -0
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +183 -0
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +30 -0
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +508 -0
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +544 -899
- data/lib/active_record/connection_adapters/schema_cache.rb +76 -16
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +595 -16
- data/lib/active_record/connection_handling.rb +98 -0
- data/lib/active_record/core.rb +472 -0
- data/lib/active_record/counter_cache.rb +107 -108
- data/lib/active_record/dynamic_matchers.rb +115 -63
- data/lib/active_record/errors.rb +36 -18
- data/lib/active_record/explain.rb +15 -63
- data/lib/active_record/explain_registry.rb +30 -0
- data/lib/active_record/explain_subscriber.rb +8 -4
- data/lib/active_record/fixture_set/file.rb +55 -0
- data/lib/active_record/fixtures.rb +159 -155
- data/lib/active_record/inheritance.rb +93 -59
- data/lib/active_record/integration.rb +8 -8
- data/lib/active_record/locale/en.yml +8 -1
- data/lib/active_record/locking/optimistic.rb +39 -43
- data/lib/active_record/locking/pessimistic.rb +4 -4
- data/lib/active_record/log_subscriber.rb +19 -9
- data/lib/active_record/migration/command_recorder.rb +102 -33
- data/lib/active_record/migration/join_table.rb +15 -0
- data/lib/active_record/migration.rb +411 -173
- data/lib/active_record/model_schema.rb +81 -94
- data/lib/active_record/nested_attributes.rb +173 -131
- data/lib/active_record/null_relation.rb +67 -0
- data/lib/active_record/persistence.rb +254 -106
- data/lib/active_record/query_cache.rb +18 -36
- data/lib/active_record/querying.rb +19 -15
- data/lib/active_record/railtie.rb +113 -38
- data/lib/active_record/railties/console_sandbox.rb +3 -4
- data/lib/active_record/railties/controller_runtime.rb +4 -3
- data/lib/active_record/railties/databases.rake +115 -368
- data/lib/active_record/railties/jdbcmysql_error.rb +1 -1
- data/lib/active_record/readonly_attributes.rb +7 -3
- data/lib/active_record/reflection.rb +110 -61
- data/lib/active_record/relation/batches.rb +29 -29
- data/lib/active_record/relation/calculations.rb +155 -125
- data/lib/active_record/relation/delegation.rb +94 -18
- data/lib/active_record/relation/finder_methods.rb +151 -203
- data/lib/active_record/relation/merger.rb +188 -0
- data/lib/active_record/relation/predicate_builder.rb +85 -42
- data/lib/active_record/relation/query_methods.rb +793 -146
- data/lib/active_record/relation/spawn_methods.rb +43 -150
- data/lib/active_record/relation.rb +293 -173
- data/lib/active_record/result.rb +48 -7
- data/lib/active_record/runtime_registry.rb +17 -0
- data/lib/active_record/sanitization.rb +41 -54
- data/lib/active_record/schema.rb +19 -12
- data/lib/active_record/schema_dumper.rb +41 -41
- data/lib/active_record/schema_migration.rb +46 -0
- data/lib/active_record/scoping/default.rb +56 -52
- data/lib/active_record/scoping/named.rb +78 -103
- data/lib/active_record/scoping.rb +54 -124
- data/lib/active_record/serialization.rb +6 -2
- data/lib/active_record/serializers/xml_serializer.rb +9 -15
- data/lib/active_record/statement_cache.rb +26 -0
- data/lib/active_record/store.rb +131 -15
- data/lib/active_record/tasks/database_tasks.rb +204 -0
- data/lib/active_record/tasks/firebird_database_tasks.rb +56 -0
- data/lib/active_record/tasks/mysql_database_tasks.rb +144 -0
- data/lib/active_record/tasks/oracle_database_tasks.rb +45 -0
- data/lib/active_record/tasks/postgresql_database_tasks.rb +90 -0
- data/lib/active_record/tasks/sqlite_database_tasks.rb +51 -0
- data/lib/active_record/tasks/sqlserver_database_tasks.rb +48 -0
- data/lib/active_record/test_case.rb +67 -38
- data/lib/active_record/timestamp.rb +16 -11
- data/lib/active_record/transactions.rb +73 -51
- data/lib/active_record/validations/associated.rb +19 -13
- data/lib/active_record/validations/presence.rb +65 -0
- data/lib/active_record/validations/uniqueness.rb +110 -57
- data/lib/active_record/validations.rb +18 -17
- data/lib/active_record/version.rb +7 -6
- data/lib/active_record.rb +63 -45
- data/lib/rails/generators/active_record/migration/migration_generator.rb +45 -8
- data/lib/rails/generators/active_record/{model/templates/migration.rb → migration/templates/create_table_migration.rb} +4 -0
- data/lib/rails/generators/active_record/migration/templates/migration.rb +20 -15
- data/lib/rails/generators/active_record/model/model_generator.rb +5 -4
- data/lib/rails/generators/active_record/model/templates/model.rb +4 -6
- data/lib/rails/generators/active_record/model/templates/module.rb +1 -1
- data/lib/rails/generators/active_record.rb +3 -5
- metadata +43 -29
- data/examples/associations.png +0 -0
- data/lib/active_record/attribute_methods/deprecated_underscore_read.rb +0 -32
- data/lib/active_record/connection_adapters/abstract/connection_specification.rb +0 -191
- data/lib/active_record/connection_adapters/sqlite_adapter.rb +0 -583
- data/lib/active_record/dynamic_finder_match.rb +0 -68
- data/lib/active_record/dynamic_scope_match.rb +0 -23
- data/lib/active_record/fixtures/file.rb +0 -65
- data/lib/active_record/identity_map.rb +0 -162
- data/lib/active_record/observer.rb +0 -121
- data/lib/active_record/session_store.rb +0 -360
- data/lib/rails/generators/active_record/migration.rb +0 -15
- data/lib/rails/generators/active_record/observer/observer_generator.rb +0 -15
- data/lib/rails/generators/active_record/observer/templates/observer.rb +0 -4
- data/lib/rails/generators/active_record/session_migration/session_migration_generator.rb +0 -25
- data/lib/rails/generators/active_record/session_migration/templates/migration.rb +0 -12
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'active_support/concern'
|
2
|
-
|
3
1
|
module ActiveRecord
|
4
2
|
module ModelSchema
|
5
3
|
extend ActiveSupport::Concern
|
@@ -12,8 +10,7 @@ module ActiveRecord
|
|
12
10
|
# the Product class will look for "productid" instead of "id" as the primary column. If the
|
13
11
|
# latter is specified, the Product class will look for "product_id" instead of "id". Remember
|
14
12
|
# that this is a global setting for all Active Records.
|
15
|
-
|
16
|
-
self.primary_key_prefix_type = nil
|
13
|
+
mattr_accessor :primary_key_prefix_type, instance_writer: false
|
17
14
|
|
18
15
|
##
|
19
16
|
# :singleton-method:
|
@@ -25,14 +22,14 @@ module ActiveRecord
|
|
25
22
|
# If you are organising your models within modules you can add a prefix to the models within
|
26
23
|
# a namespace by defining a singleton method in the parent module called table_name_prefix which
|
27
24
|
# returns your chosen prefix.
|
28
|
-
class_attribute :table_name_prefix, :
|
25
|
+
class_attribute :table_name_prefix, instance_writer: false
|
29
26
|
self.table_name_prefix = ""
|
30
27
|
|
31
28
|
##
|
32
29
|
# :singleton-method:
|
33
30
|
# Works like +table_name_prefix+, but appends instead of prepends (set to "_basecamp" gives "projects_basecamp",
|
34
31
|
# "people_basecamp"). By default, the suffix is the empty string.
|
35
|
-
class_attribute :table_name_suffix, :
|
32
|
+
class_attribute :table_name_suffix, instance_writer: false
|
36
33
|
self.table_name_suffix = ""
|
37
34
|
|
38
35
|
##
|
@@ -40,8 +37,10 @@ module ActiveRecord
|
|
40
37
|
# Indicates whether table names should be the pluralized versions of the corresponding class names.
|
41
38
|
# If true, the default table name for a Product class will be +products+. If false, it would just be +product+.
|
42
39
|
# See table_name for the full rules on table/class naming. This is true, by default.
|
43
|
-
class_attribute :pluralize_table_names, :
|
40
|
+
class_attribute :pluralize_table_names, instance_writer: false
|
44
41
|
self.pluralize_table_names = true
|
42
|
+
|
43
|
+
self.inheritance_column = 'type'
|
45
44
|
end
|
46
45
|
|
47
46
|
module ClassMethods
|
@@ -105,10 +104,6 @@ module ActiveRecord
|
|
105
104
|
@table_name
|
106
105
|
end
|
107
106
|
|
108
|
-
def original_table_name #:nodoc:
|
109
|
-
deprecated_original_property_getter :table_name
|
110
|
-
end
|
111
|
-
|
112
107
|
# Sets the table name explicitly. Example:
|
113
108
|
#
|
114
109
|
# class Project < ActiveRecord::Base
|
@@ -118,17 +113,17 @@ module ActiveRecord
|
|
118
113
|
# You can also just define your own <tt>self.table_name</tt> method; see
|
119
114
|
# the documentation for ActiveRecord::Base#table_name.
|
120
115
|
def table_name=(value)
|
121
|
-
|
122
|
-
@table_name = value && value.to_s
|
123
|
-
@quoted_table_name = nil
|
124
|
-
@arel_table = nil
|
125
|
-
@relation = Relation.new(self, arel_table)
|
126
|
-
end
|
116
|
+
value = value && value.to_s
|
127
117
|
|
128
|
-
|
129
|
-
|
118
|
+
if defined?(@table_name)
|
119
|
+
return if value == @table_name
|
120
|
+
reset_column_information if connected?
|
121
|
+
end
|
122
|
+
|
123
|
+
@table_name = value
|
130
124
|
@quoted_table_name = nil
|
131
125
|
@arel_table = nil
|
126
|
+
@sequence_name = nil unless defined?(@explicit_sequence_name) && @explicit_sequence_name
|
132
127
|
@relation = Relation.new(self, arel_table)
|
133
128
|
end
|
134
129
|
|
@@ -139,16 +134,12 @@ module ActiveRecord
|
|
139
134
|
|
140
135
|
# Computes the table name, (re)sets it internally, and returns it.
|
141
136
|
def reset_table_name #:nodoc:
|
142
|
-
if abstract_class?
|
143
|
-
|
144
|
-
nil
|
145
|
-
else
|
146
|
-
superclass.table_name
|
147
|
-
end
|
137
|
+
self.table_name = if abstract_class?
|
138
|
+
superclass == Base ? nil : superclass.table_name
|
148
139
|
elsif superclass.abstract_class?
|
149
|
-
|
140
|
+
superclass.table_name || compute_table_name
|
150
141
|
else
|
151
|
-
|
142
|
+
compute_table_name
|
152
143
|
end
|
153
144
|
end
|
154
145
|
|
@@ -156,30 +147,25 @@ module ActiveRecord
|
|
156
147
|
(parents.detect{ |p| p.respond_to?(:table_name_prefix) } || self).table_name_prefix
|
157
148
|
end
|
158
149
|
|
159
|
-
#
|
150
|
+
# Defines the name of the table column which will store the class name on single-table
|
151
|
+
# inheritance situations.
|
152
|
+
#
|
153
|
+
# The default inheritance column name is +type+, which means it's a
|
154
|
+
# reserved word inside Active Record. To be able to use single-table
|
155
|
+
# inheritance with another column name, or to use the column +type+ in
|
156
|
+
# your own model for something else, you can set +inheritance_column+:
|
157
|
+
#
|
158
|
+
# self.inheritance_column = 'zoink'
|
160
159
|
def inheritance_column
|
161
|
-
|
162
|
-
(@inheritance_column ||= nil) || 'type'
|
163
|
-
else
|
164
|
-
(@inheritance_column ||= nil) || superclass.inheritance_column
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
def original_inheritance_column #:nodoc:
|
169
|
-
deprecated_original_property_getter :inheritance_column
|
160
|
+
(@inheritance_column ||= nil) || superclass.inheritance_column
|
170
161
|
end
|
171
162
|
|
172
163
|
# Sets the value of inheritance_column
|
173
164
|
def inheritance_column=(value)
|
174
|
-
@
|
175
|
-
@inheritance_column = value.to_s
|
165
|
+
@inheritance_column = value.to_s
|
176
166
|
@explicit_inheritance_column = true
|
177
167
|
end
|
178
168
|
|
179
|
-
def set_inheritance_column(value = nil, &block) #:nodoc:
|
180
|
-
deprecated_property_setter :inheritance_column, value, block
|
181
|
-
end
|
182
|
-
|
183
169
|
def sequence_name
|
184
170
|
if base_class == self
|
185
171
|
@sequence_name ||= reset_sequence_name
|
@@ -188,12 +174,9 @@ module ActiveRecord
|
|
188
174
|
end
|
189
175
|
end
|
190
176
|
|
191
|
-
def original_sequence_name #:nodoc:
|
192
|
-
deprecated_original_property_getter :sequence_name
|
193
|
-
end
|
194
|
-
|
195
177
|
def reset_sequence_name #:nodoc:
|
196
|
-
|
178
|
+
@explicit_sequence_name = false
|
179
|
+
@sequence_name = connection.default_sequence_name(table_name, primary_key)
|
197
180
|
end
|
198
181
|
|
199
182
|
# Sets the name of the sequence to use when generating ids to the given
|
@@ -211,12 +194,8 @@ module ActiveRecord
|
|
211
194
|
# self.sequence_name = "projectseq" # default would have been "project_seq"
|
212
195
|
# end
|
213
196
|
def sequence_name=(value)
|
214
|
-
@original_sequence_name = @sequence_name if defined?(@sequence_name)
|
215
197
|
@sequence_name = value.to_s
|
216
|
-
|
217
|
-
|
218
|
-
def set_sequence_name(value = nil, &block) #:nodoc:
|
219
|
-
deprecated_property_setter :sequence_name, value, block
|
198
|
+
@explicit_sequence_name = true
|
220
199
|
end
|
221
200
|
|
222
201
|
# Indicates whether the table associated with this class exists
|
@@ -226,7 +205,7 @@ module ActiveRecord
|
|
226
205
|
|
227
206
|
# Returns an array of column objects for the table associated with this class.
|
228
207
|
def columns
|
229
|
-
@columns ||= connection.schema_cache.columns
|
208
|
+
@columns ||= connection.schema_cache.columns(table_name).map do |col|
|
230
209
|
col = col.dup
|
231
210
|
col.primary = (col.name == primary_key)
|
232
211
|
col
|
@@ -238,6 +217,32 @@ module ActiveRecord
|
|
238
217
|
@columns_hash ||= Hash[columns.map { |c| [c.name, c] }]
|
239
218
|
end
|
240
219
|
|
220
|
+
def column_types # :nodoc:
|
221
|
+
@column_types ||= decorate_columns(columns_hash.dup)
|
222
|
+
end
|
223
|
+
|
224
|
+
def decorate_columns(columns_hash) # :nodoc:
|
225
|
+
return if columns_hash.empty?
|
226
|
+
|
227
|
+
@serialized_column_names ||= self.columns_hash.keys.find_all do |name|
|
228
|
+
serialized_attributes.key?(name)
|
229
|
+
end
|
230
|
+
|
231
|
+
@serialized_column_names.each do |name|
|
232
|
+
columns_hash[name] = AttributeMethods::Serialization::Type.new(columns_hash[name])
|
233
|
+
end
|
234
|
+
|
235
|
+
@time_zone_column_names ||= self.columns_hash.find_all do |name, col|
|
236
|
+
create_time_zone_conversion_attribute?(name, col)
|
237
|
+
end.map!(&:first)
|
238
|
+
|
239
|
+
@time_zone_column_names.each do |name|
|
240
|
+
columns_hash[name] = AttributeMethods::TimeZoneConversion::Type.new(columns_hash[name])
|
241
|
+
end
|
242
|
+
|
243
|
+
columns_hash
|
244
|
+
end
|
245
|
+
|
241
246
|
# Returns a hash where the keys are column names and the values are
|
242
247
|
# default values when instantiating the AR object for this table.
|
243
248
|
def column_defaults
|
@@ -259,13 +264,12 @@ module ActiveRecord
|
|
259
264
|
# and true as the value. This makes it possible to do O(1) lookups in respond_to? to check if a given method for attribute
|
260
265
|
# is available.
|
261
266
|
def column_methods_hash #:nodoc:
|
262
|
-
@dynamic_methods_hash ||= column_names.
|
267
|
+
@dynamic_methods_hash ||= column_names.each_with_object(Hash.new(false)) do |attr, methods|
|
263
268
|
attr_name = attr.to_s
|
264
269
|
methods[attr.to_sym] = attr_name
|
265
270
|
methods["#{attr}=".to_sym] = attr_name
|
266
271
|
methods["#{attr}?".to_sym] = attr_name
|
267
272
|
methods["#{attr}_before_type_cast".to_sym] = attr_name
|
268
|
-
methods
|
269
273
|
end
|
270
274
|
end
|
271
275
|
|
@@ -287,7 +291,7 @@ module ActiveRecord
|
|
287
291
|
#
|
288
292
|
# JobLevel.reset_column_information
|
289
293
|
# %w{assistant executive manager director}.each do |type|
|
290
|
-
# JobLevel.create(:
|
294
|
+
# JobLevel.create(name: type)
|
291
295
|
# end
|
292
296
|
# end
|
293
297
|
#
|
@@ -300,14 +304,26 @@ module ActiveRecord
|
|
300
304
|
undefine_attribute_methods
|
301
305
|
connection.schema_cache.clear_table_cache!(table_name) if table_exists?
|
302
306
|
|
303
|
-
@
|
304
|
-
@
|
305
|
-
@
|
306
|
-
@
|
307
|
+
@arel_engine = nil
|
308
|
+
@column_defaults = nil
|
309
|
+
@column_names = nil
|
310
|
+
@columns = nil
|
311
|
+
@columns_hash = nil
|
312
|
+
@column_types = nil
|
313
|
+
@content_columns = nil
|
314
|
+
@dynamic_methods_hash = nil
|
315
|
+
@inheritance_column = nil unless defined?(@explicit_inheritance_column) && @explicit_inheritance_column
|
316
|
+
@relation = nil
|
317
|
+
@serialized_column_names = nil
|
318
|
+
@time_zone_column_names = nil
|
319
|
+
@cached_time_zone = nil
|
307
320
|
end
|
308
321
|
|
309
|
-
|
310
|
-
|
322
|
+
# This is a hook for use by modules that need to do extra stuff to
|
323
|
+
# attributes when they are initialized. (e.g. attribute
|
324
|
+
# serialization)
|
325
|
+
def initialize_attributes(attributes, options = {}) #:nodoc:
|
326
|
+
attributes
|
311
327
|
end
|
312
328
|
|
313
329
|
private
|
@@ -315,8 +331,7 @@ module ActiveRecord
|
|
315
331
|
# Guesses the table name, but does not decorate it with prefix and suffix information.
|
316
332
|
def undecorated_table_name(class_name = base_class.name)
|
317
333
|
table_name = class_name.to_s.demodulize.underscore
|
318
|
-
|
319
|
-
table_name
|
334
|
+
pluralize_table_names ? table_name.pluralize : table_name
|
320
335
|
end
|
321
336
|
|
322
337
|
# Computes and returns a table name according to default conventions.
|
@@ -324,7 +339,7 @@ module ActiveRecord
|
|
324
339
|
base = base_class
|
325
340
|
if self == base
|
326
341
|
# Nested classes are prefixed with singular parent table name.
|
327
|
-
if parent <
|
342
|
+
if parent < Base && !parent.abstract_class?
|
328
343
|
contained = parent.table_name
|
329
344
|
contained = contained.singularize if parent.pluralize_table_names
|
330
345
|
contained += '_'
|
@@ -335,34 +350,6 @@ module ActiveRecord
|
|
335
350
|
base.table_name
|
336
351
|
end
|
337
352
|
end
|
338
|
-
|
339
|
-
def deprecated_property_setter(property, value, block)
|
340
|
-
if block
|
341
|
-
ActiveSupport::Deprecation.warn(
|
342
|
-
"Calling set_#{property} is deprecated. If you need to lazily evaluate " \
|
343
|
-
"the #{property}, define your own `self.#{property}` class method. You can use `super` " \
|
344
|
-
"to get the default #{property} where you would have called `original_#{property}`."
|
345
|
-
)
|
346
|
-
|
347
|
-
define_attr_method property, value, false, &block
|
348
|
-
else
|
349
|
-
ActiveSupport::Deprecation.warn(
|
350
|
-
"Calling set_#{property} is deprecated. Please use `self.#{property} = 'the_name'` instead."
|
351
|
-
)
|
352
|
-
|
353
|
-
define_attr_method property, value, false
|
354
|
-
end
|
355
|
-
end
|
356
|
-
|
357
|
-
def deprecated_original_property_getter(property)
|
358
|
-
ActiveSupport::Deprecation.warn("original_#{property} is deprecated. Define self.#{property} and call super instead.")
|
359
|
-
|
360
|
-
if !instance_variable_defined?("@original_#{property}") && respond_to?("reset_#{property}")
|
361
|
-
send("reset_#{property}")
|
362
|
-
else
|
363
|
-
instance_variable_get("@original_#{property}")
|
364
|
-
end
|
365
|
-
end
|
366
353
|
end
|
367
354
|
end
|
368
355
|
end
|