mack-active_record 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gems/activerecord-2.2.2/lib/active_record/aggregations.rb +261 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/association_preload.rb +374 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb +453 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb +272 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/belongs_to_association.rb +58 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/belongs_to_polymorphic_association.rb +49 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/has_and_belongs_to_many_association.rb +121 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/has_many_association.rb +121 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/has_many_through_association.rb +256 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/has_one_association.rb +115 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations/has_one_through_association.rb +31 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/associations.rb +2227 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb +387 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/base.rb +2967 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/calculations.rb +299 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/callbacks.rb +331 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb +355 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb +136 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb +201 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb +94 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/quoting.rb +69 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/schema_definitions.rb +705 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/schema_statements.rb +434 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract_adapter.rb +210 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb +585 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb +1065 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/sqlite3_adapter.rb +34 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/sqlite_adapter.rb +418 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/dirty.rb +183 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/dynamic_finder_match.rb +41 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/fixtures.rb +998 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/i18n_interpolation_deprecation.rb +26 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/locale/en.yml +54 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/locking/optimistic.rb +148 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/locking/pessimistic.rb +77 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/migration.rb +560 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/named_scope.rb +181 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/observer.rb +197 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/query_cache.rb +21 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/reflection.rb +307 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/schema.rb +51 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/schema_dumper.rb +177 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/serialization.rb +98 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/serializers/json_serializer.rb +80 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/serializers/xml_serializer.rb +338 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/test_case.rb +60 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/timestamp.rb +41 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/transactions.rb +185 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/validations.rb +1061 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record/version.rb +9 -0
- data/lib/gems/activerecord-2.2.2/lib/active_record.rb +81 -0
- data/lib/gems/activerecord-2.2.2/lib/activerecord.rb +1 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/base64.rb +33 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/basic_object.rb +24 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/buffered_logger.rb +122 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/cache/compressed_mem_cache_store.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/cache/drb_store.rb +15 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/cache/file_store.rb +72 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/cache/mem_cache_store.rb +127 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/cache/memory_store.rb +52 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/cache/synchronized_memory_store.rb +47 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/cache.rb +223 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/callbacks.rb +280 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array/access.rb +53 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array/conversions.rb +183 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array/extract_options.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array/grouping.rb +106 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array/random_access.rb +12 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/base64/encoding.rb +16 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/base64.rb +4 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/benchmark.rb +12 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/bigdecimal/conversions.rb +37 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/bigdecimal.rb +6 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/blank.rb +58 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +14 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/cgi.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/class/attribute_accessors.rb +54 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/class/delegating_attributes.rb +46 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/class/inheritable_attributes.rb +140 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/class/removal.rb +50 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/class.rb +4 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date/behavior.rb +42 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date/calculations.rb +230 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date/conversions.rb +107 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date.rb +10 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date_time/calculations.rb +126 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date_time/conversions.rb +96 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date_time.rb +12 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/duplicable.rb +43 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/enumerable.rb +107 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/exception.rb +41 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/file/atomic.rb +46 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/file.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/float/rounding.rb +24 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/float/time.rb +27 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/float.rb +7 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/conversions.rb +259 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/deep_merge.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/diff.rb +19 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/except.rb +25 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/indifferent_access.rb +137 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/keys.rb +52 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/reverse_merge.rb +35 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/slice.rb +33 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash.rb +14 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/integer/even_odd.rb +29 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/integer/inflections.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/integer/time.rb +45 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/integer.rb +9 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/agnostics.rb +11 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/daemonizing.rb +7 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/debugger.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/reporting.rb +59 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/requires.rb +24 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/load_error.rb +38 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/logger.rb +143 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/aliasing.rb +74 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/attr_accessor_with_default.rb +31 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/attr_internal.rb +32 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/attribute_accessors.rb +58 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/delegation.rb +95 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/inclusion.rb +30 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/introspection.rb +90 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/loading.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/model_naming.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/synchronization.rb +39 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/name_error.rb +17 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/numeric/bytes.rb +44 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/numeric/conversions.rb +19 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/numeric/time.rb +81 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/numeric.rb +9 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object/conversions.rb +14 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object/extending.rb +80 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object/instance_variables.rb +74 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object/metaclass.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object/misc.rb +74 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/pathname/clean_within.rb +14 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/pathname.rb +7 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/proc.rb +12 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/process/daemon.rb +25 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/process.rb +1 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/range/blockless_step.rb +32 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/range/conversions.rb +27 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/range/include_range.rb +30 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/range/overlaps.rb +15 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/range.rb +11 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/rexml.rb +36 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/access.rb +82 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/behavior.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/conversions.rb +28 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/filters.rb +26 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/inflections.rb +167 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/iterators.rb +21 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/multibyte.rb +81 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/starts_ends_with.rb +35 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/xchar.rb +11 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string.rb +22 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/symbol.rb +14 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/time/behavior.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/time/calculations.rb +303 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/time/conversions.rb +90 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/time/zones.rb +86 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/time.rb +42 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext.rb +4 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/dependencies.rb +621 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/deprecation.rb +243 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/duration.rb +96 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/gzip.rb +25 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/inflections.rb +55 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/inflector.rb +397 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/decoding.rb +63 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/date.rb +21 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/date_time.rb +21 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/enumerable.rb +12 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/false_class.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/hash.rb +47 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/nil_class.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/numeric.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/object.rb +6 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/regexp.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/string.rb +36 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/symbol.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/time.rb +21 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/true_class.rb +5 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoding.rb +37 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json/variable.rb +10 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/json.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/locale/en.yml +32 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/memoizable.rb +82 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/multibyte/chars.rb +679 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/multibyte/exceptions.rb +8 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/multibyte/unicode_database.rb +71 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/multibyte.rb +33 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/option_merger.rb +17 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/ordered_hash.rb +58 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/ordered_options.rb +19 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/rescuable.rb +108 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/secure_random.rb +197 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/string_inquirer.rb +21 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/test_case.rb +24 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/testing/core_ext/test/unit/assertions.rb +72 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/testing/core_ext/test.rb +6 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/testing/default.rb +9 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/testing/performance.rb +452 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb +120 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/time_with_zone.rb +328 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/values/time_zone.rb +403 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/blankslate.rb +113 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/css.rb +250 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb +115 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb +139 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb +63 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/xmlmarkup.rb +328 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb +216 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/i18n-0.0.1/i18n/exceptions.rb +53 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/i18n-0.0.1/i18n.rb +194 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/memcache-client-1.5.1/memcache.rb +849 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone.rb +47 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone_info.rb +228 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Algiers.rb +55 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Cairo.rb +219 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Casablanca.rb +40 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Harare.rb +18 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Johannesburg.rb +25 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Monrovia.rb +22 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Nairobi.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +166 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Bogota.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Caracas.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chicago.rb +283 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chihuahua.rb +136 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Denver.rb +204 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Godthab.rb +161 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Guatemala.rb +27 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Halifax.rb +274 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Indiana/Indianapolis.rb +149 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Juneau.rb +194 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/La_Paz.rb +22 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Lima.rb +35 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Los_Angeles.rb +232 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mazatlan.rb +139 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mexico_City.rb +144 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Monterrey.rb +131 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/New_York.rb +282 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Phoenix.rb +30 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Regina.rb +74 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Santiago.rb +205 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Sao_Paulo.rb +171 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/St_Johns.rb +288 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Tijuana.rb +196 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Almaty.rb +67 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baghdad.rb +73 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baku.rb +161 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Bangkok.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Chongqing.rb +33 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Colombo.rb +30 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Dhaka.rb +27 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Hong_Kong.rb +87 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Irkutsk.rb +165 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jakarta.rb +30 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jerusalem.rb +163 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kabul.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kamchatka.rb +163 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Karachi.rb +30 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Katmandu.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kolkata.rb +25 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Krasnoyarsk.rb +163 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuala_Lumpur.rb +31 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuwait.rb +18 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Magadan.rb +163 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Muscat.rb +18 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Novosibirsk.rb +164 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Rangoon.rb +24 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Riyadh.rb +18 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Seoul.rb +34 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Shanghai.rb +35 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Singapore.rb +33 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Taipei.rb +59 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tashkent.rb +47 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tbilisi.rb +78 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tehran.rb +121 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tokyo.rb +30 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Ulaanbaatar.rb +65 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Urumqi.rb +33 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Vladivostok.rb +164 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yakutsk.rb +163 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yekaterinburg.rb +165 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yerevan.rb +165 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Azores.rb +270 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Cape_Verde.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/South_Georgia.rb +18 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Adelaide.rb +187 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Brisbane.rb +35 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Darwin.rb +29 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Hobart.rb +193 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Melbourne.rb +185 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Perth.rb +37 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Sydney.rb +185 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Etc/UTC.rb +16 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Amsterdam.rb +228 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Athens.rb +185 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Belgrade.rb +163 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Berlin.rb +188 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bratislava.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Brussels.rb +232 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bucharest.rb +181 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Budapest.rb +197 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Copenhagen.rb +179 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Dublin.rb +276 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Helsinki.rb +163 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Istanbul.rb +218 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Kiev.rb +168 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Lisbon.rb +268 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Ljubljana.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/London.rb +288 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Madrid.rb +211 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Minsk.rb +170 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Moscow.rb +181 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Paris.rb +232 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Prague.rb +187 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Riga.rb +176 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Rome.rb +215 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sarajevo.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Skopje.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sofia.rb +173 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Stockholm.rb +165 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Tallinn.rb +172 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vienna.rb +183 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vilnius.rb +170 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Warsaw.rb +212 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Zagreb.rb +13 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Auckland.rb +202 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Fiji.rb +23 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Guam.rb +22 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Honolulu.rb +28 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Majuro.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Midway.rb +25 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Noumea.rb +25 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Pago_Pago.rb +26 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Port_Moresby.rb +20 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Tongatapu.rb +27 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/info_timezone.rb +52 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone.rb +51 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone_info.rb +44 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/offset_rationals.rb +98 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/ruby_core_support.rb +56 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/time_or_datetime.rb +292 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone.rb +508 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_definition.rb +56 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_info.rb +40 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_offset_info.rb +94 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb +198 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_transition_info.rb +129 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo.rb +33 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/xml-simple-1.0.11/xmlsimple.rb +1021 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/vendor.rb +34 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/version.rb +9 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support/whiny_nil.rb +58 -0
- data/lib/gems/activesupport-2.2.2/lib/active_support.rb +61 -0
- data/lib/gems/activesupport-2.2.2/lib/activesupport.rb +1 -0
- data/lib/gems.rb +13 -0
- data/lib/mack-active_record/database.rb +4 -4
- data/lib/mack-active_record/migration_generator/migration_generator.rb +6 -2
- data/lib/mack-active_record/model_generator/manifest.yml +3 -3
- data/lib/mack-active_record/model_generator/model_generator.rb +8 -1
- data/lib/mack-active_record/model_generator/templates/model.rb.template +1 -1
- data/lib/mack-active_record/model_generator/templates/rspec.rb.template +1 -1
- data/lib/mack-active_record/model_generator/templates/test.rb.template +1 -1
- data/lib/mack-active_record.rb +3 -1
- data/lib/mack-active_record_tasks.rb +3 -0
- metadata +457 -16
@@ -0,0 +1,272 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module Associations
|
3
|
+
# This is the root class of all association proxies:
|
4
|
+
#
|
5
|
+
# AssociationProxy
|
6
|
+
# BelongsToAssociation
|
7
|
+
# HasOneAssociation
|
8
|
+
# BelongsToPolymorphicAssociation
|
9
|
+
# AssociationCollection
|
10
|
+
# HasAndBelongsToManyAssociation
|
11
|
+
# HasManyAssociation
|
12
|
+
# HasManyThroughAssociation
|
13
|
+
# HasOneThroughAssociation
|
14
|
+
#
|
15
|
+
# Association proxies in Active Record are middlemen between the object that
|
16
|
+
# holds the association, known as the <tt>@owner</tt>, and the actual associated
|
17
|
+
# object, known as the <tt>@target</tt>. The kind of association any proxy is
|
18
|
+
# about is available in <tt>@reflection</tt>. That's an instance of the class
|
19
|
+
# ActiveRecord::Reflection::AssociationReflection.
|
20
|
+
#
|
21
|
+
# For example, given
|
22
|
+
#
|
23
|
+
# class Blog < ActiveRecord::Base
|
24
|
+
# has_many :posts
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# blog = Blog.find(:first)
|
28
|
+
#
|
29
|
+
# the association proxy in <tt>blog.posts</tt> has the object in +blog+ as
|
30
|
+
# <tt>@owner</tt>, the collection of its posts as <tt>@target</tt>, and
|
31
|
+
# the <tt>@reflection</tt> object represents a <tt>:has_many</tt> macro.
|
32
|
+
#
|
33
|
+
# This class has most of the basic instance methods removed, and delegates
|
34
|
+
# unknown methods to <tt>@target</tt> via <tt>method_missing</tt>. As a
|
35
|
+
# corner case, it even removes the +class+ method and that's why you get
|
36
|
+
#
|
37
|
+
# blog.posts.class # => Array
|
38
|
+
#
|
39
|
+
# though the object behind <tt>blog.posts</tt> is not an Array, but an
|
40
|
+
# ActiveRecord::Associations::HasManyAssociation.
|
41
|
+
#
|
42
|
+
# The <tt>@target</tt> object is not \loaded until needed. For example,
|
43
|
+
#
|
44
|
+
# blog.posts.count
|
45
|
+
#
|
46
|
+
# is computed directly through SQL and does not trigger by itself the
|
47
|
+
# instantiation of the actual post records.
|
48
|
+
class AssociationProxy #:nodoc:
|
49
|
+
alias_method :proxy_respond_to?, :respond_to?
|
50
|
+
alias_method :proxy_extend, :extend
|
51
|
+
delegate :to_param, :to => :proxy_target
|
52
|
+
instance_methods.each { |m| undef_method m unless m =~ /(^__|^nil\?$|^send$|proxy_|^object_id$)/ }
|
53
|
+
|
54
|
+
def initialize(owner, reflection)
|
55
|
+
@owner, @reflection = owner, reflection
|
56
|
+
Array(reflection.options[:extend]).each { |ext| proxy_extend(ext) }
|
57
|
+
reset
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns the owner of the proxy.
|
61
|
+
def proxy_owner
|
62
|
+
@owner
|
63
|
+
end
|
64
|
+
|
65
|
+
# Returns the reflection object that represents the association handled
|
66
|
+
# by the proxy.
|
67
|
+
def proxy_reflection
|
68
|
+
@reflection
|
69
|
+
end
|
70
|
+
|
71
|
+
# Returns the \target of the proxy, same as +target+.
|
72
|
+
def proxy_target
|
73
|
+
@target
|
74
|
+
end
|
75
|
+
|
76
|
+
# Does the proxy or its \target respond to +symbol+?
|
77
|
+
def respond_to?(*args)
|
78
|
+
proxy_respond_to?(*args) || (load_target && @target.respond_to?(*args))
|
79
|
+
end
|
80
|
+
|
81
|
+
# Forwards <tt>===</tt> explicitly to the \target because the instance method
|
82
|
+
# removal above doesn't catch it. Loads the \target if needed.
|
83
|
+
def ===(other)
|
84
|
+
load_target
|
85
|
+
other === @target
|
86
|
+
end
|
87
|
+
|
88
|
+
# Returns the name of the table of the related class:
|
89
|
+
#
|
90
|
+
# post.comments.aliased_table_name # => "comments"
|
91
|
+
#
|
92
|
+
def aliased_table_name
|
93
|
+
@reflection.klass.table_name
|
94
|
+
end
|
95
|
+
|
96
|
+
# Returns the SQL string that corresponds to the <tt>:conditions</tt>
|
97
|
+
# option of the macro, if given, or +nil+ otherwise.
|
98
|
+
def conditions
|
99
|
+
@conditions ||= interpolate_sql(@reflection.sanitized_conditions) if @reflection.sanitized_conditions
|
100
|
+
end
|
101
|
+
alias :sql_conditions :conditions
|
102
|
+
|
103
|
+
# Resets the \loaded flag to +false+ and sets the \target to +nil+.
|
104
|
+
def reset
|
105
|
+
@loaded = false
|
106
|
+
@target = nil
|
107
|
+
end
|
108
|
+
|
109
|
+
# Reloads the \target and returns +self+ on success.
|
110
|
+
def reload
|
111
|
+
reset
|
112
|
+
load_target
|
113
|
+
self unless @target.nil?
|
114
|
+
end
|
115
|
+
|
116
|
+
# Has the \target been already \loaded?
|
117
|
+
def loaded?
|
118
|
+
@loaded
|
119
|
+
end
|
120
|
+
|
121
|
+
# Asserts the \target has been loaded setting the \loaded flag to +true+.
|
122
|
+
def loaded
|
123
|
+
@loaded = true
|
124
|
+
end
|
125
|
+
|
126
|
+
# Returns the target of this proxy, same as +proxy_target+.
|
127
|
+
def target
|
128
|
+
@target
|
129
|
+
end
|
130
|
+
|
131
|
+
# Sets the target of this proxy to <tt>\target</tt>, and the \loaded flag to +true+.
|
132
|
+
def target=(target)
|
133
|
+
@target = target
|
134
|
+
loaded
|
135
|
+
end
|
136
|
+
|
137
|
+
# Forwards the call to the target. Loads the \target if needed.
|
138
|
+
def inspect
|
139
|
+
load_target
|
140
|
+
@target.inspect
|
141
|
+
end
|
142
|
+
|
143
|
+
def send(method, *args)
|
144
|
+
if proxy_respond_to?(method)
|
145
|
+
super
|
146
|
+
else
|
147
|
+
load_target
|
148
|
+
@target.send(method, *args)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
protected
|
153
|
+
# Does the association have a <tt>:dependent</tt> option?
|
154
|
+
def dependent?
|
155
|
+
@reflection.options[:dependent]
|
156
|
+
end
|
157
|
+
|
158
|
+
# Returns a string with the IDs of +records+ joined with a comma, quoted
|
159
|
+
# if needed. The result is ready to be inserted into a SQL IN clause.
|
160
|
+
#
|
161
|
+
# quoted_record_ids(records) # => "23,56,58,67"
|
162
|
+
#
|
163
|
+
def quoted_record_ids(records)
|
164
|
+
records.map { |record| record.quoted_id }.join(',')
|
165
|
+
end
|
166
|
+
|
167
|
+
def interpolate_sql(sql, record = nil)
|
168
|
+
@owner.send(:interpolate_sql, sql, record)
|
169
|
+
end
|
170
|
+
|
171
|
+
# Forwards the call to the reflection class.
|
172
|
+
def sanitize_sql(sql)
|
173
|
+
@reflection.klass.send(:sanitize_sql, sql)
|
174
|
+
end
|
175
|
+
|
176
|
+
# Assigns the ID of the owner to the corresponding foreign key in +record+.
|
177
|
+
# If the association is polymorphic the type of the owner is also set.
|
178
|
+
def set_belongs_to_association_for(record)
|
179
|
+
if @reflection.options[:as]
|
180
|
+
record["#{@reflection.options[:as]}_id"] = @owner.id unless @owner.new_record?
|
181
|
+
record["#{@reflection.options[:as]}_type"] = @owner.class.base_class.name.to_s
|
182
|
+
else
|
183
|
+
record[@reflection.primary_key_name] = @owner.id unless @owner.new_record?
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
# Merges into +options+ the ones coming from the reflection.
|
188
|
+
def merge_options_from_reflection!(options)
|
189
|
+
options.reverse_merge!(
|
190
|
+
:group => @reflection.options[:group],
|
191
|
+
:limit => @reflection.options[:limit],
|
192
|
+
:offset => @reflection.options[:offset],
|
193
|
+
:joins => @reflection.options[:joins],
|
194
|
+
:include => @reflection.options[:include],
|
195
|
+
:select => @reflection.options[:select],
|
196
|
+
:readonly => @reflection.options[:readonly]
|
197
|
+
)
|
198
|
+
end
|
199
|
+
|
200
|
+
# Forwards +with_scope+ to the reflection.
|
201
|
+
def with_scope(*args, &block)
|
202
|
+
@reflection.klass.send :with_scope, *args, &block
|
203
|
+
end
|
204
|
+
|
205
|
+
private
|
206
|
+
# Forwards any missing method call to the \target.
|
207
|
+
def method_missing(method, *args)
|
208
|
+
if load_target
|
209
|
+
raise NoMethodError unless @target.respond_to?(method)
|
210
|
+
|
211
|
+
if block_given?
|
212
|
+
@target.send(method, *args) { |*block_args| yield(*block_args) }
|
213
|
+
else
|
214
|
+
@target.send(method, *args)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
# Loads the \target if needed and returns it.
|
220
|
+
#
|
221
|
+
# This method is abstract in the sense that it relies on +find_target+,
|
222
|
+
# which is expected to be provided by descendants.
|
223
|
+
#
|
224
|
+
# If the \target is already \loaded it is just returned. Thus, you can call
|
225
|
+
# +load_target+ unconditionally to get the \target.
|
226
|
+
#
|
227
|
+
# ActiveRecord::RecordNotFound is rescued within the method, and it is
|
228
|
+
# not reraised. The proxy is \reset and +nil+ is the return value.
|
229
|
+
def load_target
|
230
|
+
return nil unless defined?(@loaded)
|
231
|
+
|
232
|
+
if !loaded? and (!@owner.new_record? || foreign_key_present)
|
233
|
+
@target = find_target
|
234
|
+
end
|
235
|
+
|
236
|
+
@loaded = true
|
237
|
+
@target
|
238
|
+
rescue ActiveRecord::RecordNotFound
|
239
|
+
reset
|
240
|
+
end
|
241
|
+
|
242
|
+
# Can be overwritten by associations that might have the foreign key
|
243
|
+
# available for an association without having the object itself (and
|
244
|
+
# still being a new record). Currently, only +belongs_to+ presents
|
245
|
+
# this scenario (both vanilla and polymorphic).
|
246
|
+
def foreign_key_present
|
247
|
+
false
|
248
|
+
end
|
249
|
+
|
250
|
+
# Raises ActiveRecord::AssociationTypeMismatch unless +record+ is of
|
251
|
+
# the kind of the class of the associated objects. Meant to be used as
|
252
|
+
# a sanity check when you are about to assign an associated record.
|
253
|
+
def raise_on_type_mismatch(record)
|
254
|
+
unless record.is_a?(@reflection.klass) || record.is_a?(@reflection.class_name.constantize)
|
255
|
+
message = "#{@reflection.class_name}(##{@reflection.klass.object_id}) expected, got #{record.class}(##{record.class.object_id})"
|
256
|
+
raise ActiveRecord::AssociationTypeMismatch, message
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
# Array#flatten has problems with recursive arrays. Going one level
|
261
|
+
# deeper solves the majority of the problems.
|
262
|
+
def flatten_deeper(array)
|
263
|
+
array.collect { |element| (element.respond_to?(:flatten) && !element.is_a?(Hash)) ? element.flatten : element }.flatten
|
264
|
+
end
|
265
|
+
|
266
|
+
# Returns the ID of the owner, quoted if needed.
|
267
|
+
def owner_quoted_id
|
268
|
+
@owner.quoted_id
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module Associations
|
3
|
+
class BelongsToAssociation < AssociationProxy #:nodoc:
|
4
|
+
def create(attributes = {})
|
5
|
+
replace(@reflection.create_association(attributes))
|
6
|
+
end
|
7
|
+
|
8
|
+
def build(attributes = {})
|
9
|
+
replace(@reflection.build_association(attributes))
|
10
|
+
end
|
11
|
+
|
12
|
+
def replace(record)
|
13
|
+
counter_cache_name = @reflection.counter_cache_column
|
14
|
+
|
15
|
+
if record.nil?
|
16
|
+
if counter_cache_name && !@owner.new_record?
|
17
|
+
@reflection.klass.decrement_counter(counter_cache_name, @owner[@reflection.primary_key_name]) if @owner[@reflection.primary_key_name]
|
18
|
+
end
|
19
|
+
|
20
|
+
@target = @owner[@reflection.primary_key_name] = nil
|
21
|
+
else
|
22
|
+
raise_on_type_mismatch(record)
|
23
|
+
|
24
|
+
if counter_cache_name && !@owner.new_record?
|
25
|
+
@reflection.klass.increment_counter(counter_cache_name, record.id)
|
26
|
+
@reflection.klass.decrement_counter(counter_cache_name, @owner[@reflection.primary_key_name]) if @owner[@reflection.primary_key_name]
|
27
|
+
end
|
28
|
+
|
29
|
+
@target = (AssociationProxy === record ? record.target : record)
|
30
|
+
@owner[@reflection.primary_key_name] = record.id unless record.new_record?
|
31
|
+
@updated = true
|
32
|
+
end
|
33
|
+
|
34
|
+
loaded
|
35
|
+
record
|
36
|
+
end
|
37
|
+
|
38
|
+
def updated?
|
39
|
+
@updated
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def find_target
|
44
|
+
@reflection.klass.find(
|
45
|
+
@owner[@reflection.primary_key_name],
|
46
|
+
:select => @reflection.options[:select],
|
47
|
+
:conditions => conditions,
|
48
|
+
:include => @reflection.options[:include],
|
49
|
+
:readonly => @reflection.options[:readonly]
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
def foreign_key_present
|
54
|
+
!@owner[@reflection.primary_key_name].nil?
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module Associations
|
3
|
+
class BelongsToPolymorphicAssociation < AssociationProxy #:nodoc:
|
4
|
+
def replace(record)
|
5
|
+
if record.nil?
|
6
|
+
@target = @owner[@reflection.primary_key_name] = @owner[@reflection.options[:foreign_type]] = nil
|
7
|
+
else
|
8
|
+
@target = (AssociationProxy === record ? record.target : record)
|
9
|
+
|
10
|
+
@owner[@reflection.primary_key_name] = record.id
|
11
|
+
@owner[@reflection.options[:foreign_type]] = record.class.base_class.name.to_s
|
12
|
+
|
13
|
+
@updated = true
|
14
|
+
end
|
15
|
+
|
16
|
+
loaded
|
17
|
+
record
|
18
|
+
end
|
19
|
+
|
20
|
+
def updated?
|
21
|
+
@updated
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def find_target
|
26
|
+
return nil if association_class.nil?
|
27
|
+
|
28
|
+
if @reflection.options[:conditions]
|
29
|
+
association_class.find(
|
30
|
+
@owner[@reflection.primary_key_name],
|
31
|
+
:select => @reflection.options[:select],
|
32
|
+
:conditions => conditions,
|
33
|
+
:include => @reflection.options[:include]
|
34
|
+
)
|
35
|
+
else
|
36
|
+
association_class.find(@owner[@reflection.primary_key_name], :select => @reflection.options[:select], :include => @reflection.options[:include])
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def foreign_key_present
|
41
|
+
!@owner[@reflection.primary_key_name].nil?
|
42
|
+
end
|
43
|
+
|
44
|
+
def association_class
|
45
|
+
@owner[@reflection.options[:foreign_type]] ? @owner[@reflection.options[:foreign_type]].constantize : nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module Associations
|
3
|
+
class HasAndBelongsToManyAssociation < AssociationCollection #:nodoc:
|
4
|
+
def create(attributes = {})
|
5
|
+
create_record(attributes) { |record| insert_record(record) }
|
6
|
+
end
|
7
|
+
|
8
|
+
def create!(attributes = {})
|
9
|
+
create_record(attributes) { |record| insert_record(record, true) }
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
def construct_find_options!(options)
|
14
|
+
options[:joins] = @join_sql
|
15
|
+
options[:readonly] = finding_with_ambiguous_select?(options[:select] || @reflection.options[:select])
|
16
|
+
options[:select] ||= (@reflection.options[:select] || '*')
|
17
|
+
end
|
18
|
+
|
19
|
+
def count_records
|
20
|
+
load_target.size
|
21
|
+
end
|
22
|
+
|
23
|
+
def insert_record(record, force=true)
|
24
|
+
if record.new_record?
|
25
|
+
if force
|
26
|
+
record.save!
|
27
|
+
else
|
28
|
+
return false unless record.save
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
if @reflection.options[:insert_sql]
|
33
|
+
@owner.connection.insert(interpolate_sql(@reflection.options[:insert_sql], record))
|
34
|
+
else
|
35
|
+
columns = @owner.connection.columns(@reflection.options[:join_table], "#{@reflection.options[:join_table]} Columns")
|
36
|
+
|
37
|
+
attributes = columns.inject({}) do |attrs, column|
|
38
|
+
case column.name.to_s
|
39
|
+
when @reflection.primary_key_name.to_s
|
40
|
+
attrs[column.name] = owner_quoted_id
|
41
|
+
when @reflection.association_foreign_key.to_s
|
42
|
+
attrs[column.name] = record.quoted_id
|
43
|
+
else
|
44
|
+
if record.has_attribute?(column.name)
|
45
|
+
value = @owner.send(:quote_value, record[column.name], column)
|
46
|
+
attrs[column.name] = value unless value.nil?
|
47
|
+
end
|
48
|
+
end
|
49
|
+
attrs
|
50
|
+
end
|
51
|
+
|
52
|
+
sql =
|
53
|
+
"INSERT INTO #{@owner.connection.quote_table_name @reflection.options[:join_table]} (#{@owner.send(:quoted_column_names, attributes).join(', ')}) " +
|
54
|
+
"VALUES (#{attributes.values.join(', ')})"
|
55
|
+
|
56
|
+
@owner.connection.insert(sql)
|
57
|
+
end
|
58
|
+
|
59
|
+
return true
|
60
|
+
end
|
61
|
+
|
62
|
+
def delete_records(records)
|
63
|
+
if sql = @reflection.options[:delete_sql]
|
64
|
+
records.each { |record| @owner.connection.delete(interpolate_sql(sql, record)) }
|
65
|
+
else
|
66
|
+
ids = quoted_record_ids(records)
|
67
|
+
sql = "DELETE FROM #{@owner.connection.quote_table_name @reflection.options[:join_table]} WHERE #{@reflection.primary_key_name} = #{owner_quoted_id} AND #{@reflection.association_foreign_key} IN (#{ids})"
|
68
|
+
@owner.connection.delete(sql)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def construct_sql
|
73
|
+
if @reflection.options[:finder_sql]
|
74
|
+
@finder_sql = interpolate_sql(@reflection.options[:finder_sql])
|
75
|
+
else
|
76
|
+
@finder_sql = "#{@owner.connection.quote_table_name @reflection.options[:join_table]}.#{@reflection.primary_key_name} = #{owner_quoted_id} "
|
77
|
+
@finder_sql << " AND (#{conditions})" if conditions
|
78
|
+
end
|
79
|
+
|
80
|
+
@join_sql = "INNER JOIN #{@owner.connection.quote_table_name @reflection.options[:join_table]} ON #{@reflection.quoted_table_name}.#{@reflection.klass.primary_key} = #{@owner.connection.quote_table_name @reflection.options[:join_table]}.#{@reflection.association_foreign_key}"
|
81
|
+
|
82
|
+
if @reflection.options[:counter_sql]
|
83
|
+
@counter_sql = interpolate_sql(@reflection.options[:counter_sql])
|
84
|
+
elsif @reflection.options[:finder_sql]
|
85
|
+
# replace the SELECT clause with COUNT(*), preserving any hints within /* ... */
|
86
|
+
@reflection.options[:counter_sql] = @reflection.options[:finder_sql].sub(/SELECT (\/\*.*?\*\/ )?(.*)\bFROM\b/im) { "SELECT #{$1}COUNT(*) FROM" }
|
87
|
+
@counter_sql = interpolate_sql(@reflection.options[:counter_sql])
|
88
|
+
else
|
89
|
+
@counter_sql = @finder_sql
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def construct_scope
|
94
|
+
{ :find => { :conditions => @finder_sql,
|
95
|
+
:joins => @join_sql,
|
96
|
+
:readonly => false,
|
97
|
+
:order => @reflection.options[:order],
|
98
|
+
:include => @reflection.options[:include],
|
99
|
+
:limit => @reflection.options[:limit] } }
|
100
|
+
end
|
101
|
+
|
102
|
+
# Join tables with additional columns on top of the two foreign keys must be considered ambiguous unless a select
|
103
|
+
# clause has been explicitly defined. Otherwise you can get broken records back, if, for example, the join column also has
|
104
|
+
# an id column. This will then overwrite the id column of the records coming back.
|
105
|
+
def finding_with_ambiguous_select?(select_clause)
|
106
|
+
!select_clause && @owner.connection.columns(@reflection.options[:join_table], "Join Table Columns").size != 2
|
107
|
+
end
|
108
|
+
|
109
|
+
private
|
110
|
+
def create_record(attributes, &block)
|
111
|
+
# Can't use Base.create because the foreign key may be a protected attribute.
|
112
|
+
ensure_owner_is_not_new
|
113
|
+
if attributes.is_a?(Array)
|
114
|
+
attributes.collect { |attr| create(attr) }
|
115
|
+
else
|
116
|
+
build_record(attributes, &block)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module Associations
|
3
|
+
# This is the proxy that handles a has many association.
|
4
|
+
#
|
5
|
+
# If the association has a <tt>:through</tt> option further specialization
|
6
|
+
# is provided by its child HasManyThroughAssociation.
|
7
|
+
class HasManyAssociation < AssociationCollection #:nodoc:
|
8
|
+
protected
|
9
|
+
def owner_quoted_id
|
10
|
+
if @reflection.options[:primary_key]
|
11
|
+
quote_value(@owner.send(@reflection.options[:primary_key]))
|
12
|
+
else
|
13
|
+
@owner.quoted_id
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns the number of records in this collection.
|
18
|
+
#
|
19
|
+
# If the association has a counter cache it gets that value. Otherwise
|
20
|
+
# it will attempt to do a count via SQL, bounded to <tt>:limit</tt> if
|
21
|
+
# there's one. Some configuration options like :group make it impossible
|
22
|
+
# to do a SQL count, in those cases the array count will be used.
|
23
|
+
#
|
24
|
+
# That does not depend on whether the collection has already been loaded
|
25
|
+
# or not. The +size+ method is the one that takes the loaded flag into
|
26
|
+
# account and delegates to +count_records+ if needed.
|
27
|
+
#
|
28
|
+
# If the collection is empty the target is set to an empty array and
|
29
|
+
# the loaded flag is set to true as well.
|
30
|
+
def count_records
|
31
|
+
count = if has_cached_counter?
|
32
|
+
@owner.send(:read_attribute, cached_counter_attribute_name)
|
33
|
+
elsif @reflection.options[:counter_sql]
|
34
|
+
@reflection.klass.count_by_sql(@counter_sql)
|
35
|
+
else
|
36
|
+
@reflection.klass.count(:conditions => @counter_sql, :include => @reflection.options[:include])
|
37
|
+
end
|
38
|
+
|
39
|
+
# If there's nothing in the database and @target has no new records
|
40
|
+
# we are certain the current target is an empty array. This is a
|
41
|
+
# documented side-effect of the method that may avoid an extra SELECT.
|
42
|
+
@target ||= [] and loaded if count == 0
|
43
|
+
|
44
|
+
if @reflection.options[:limit]
|
45
|
+
count = [ @reflection.options[:limit], count ].min
|
46
|
+
end
|
47
|
+
|
48
|
+
return count
|
49
|
+
end
|
50
|
+
|
51
|
+
def has_cached_counter?
|
52
|
+
@owner.attribute_present?(cached_counter_attribute_name)
|
53
|
+
end
|
54
|
+
|
55
|
+
def cached_counter_attribute_name
|
56
|
+
"#{@reflection.name}_count"
|
57
|
+
end
|
58
|
+
|
59
|
+
def insert_record(record)
|
60
|
+
set_belongs_to_association_for(record)
|
61
|
+
record.save
|
62
|
+
end
|
63
|
+
|
64
|
+
# Deletes the records according to the <tt>:dependent</tt> option.
|
65
|
+
def delete_records(records)
|
66
|
+
case @reflection.options[:dependent]
|
67
|
+
when :destroy
|
68
|
+
records.each { |r| r.destroy }
|
69
|
+
when :delete_all
|
70
|
+
@reflection.klass.delete(records.map { |record| record.id })
|
71
|
+
else
|
72
|
+
ids = quoted_record_ids(records)
|
73
|
+
@reflection.klass.update_all(
|
74
|
+
"#{@reflection.primary_key_name} = NULL",
|
75
|
+
"#{@reflection.primary_key_name} = #{owner_quoted_id} AND #{@reflection.klass.primary_key} IN (#{ids})"
|
76
|
+
)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def target_obsolete?
|
81
|
+
false
|
82
|
+
end
|
83
|
+
|
84
|
+
def construct_sql
|
85
|
+
case
|
86
|
+
when @reflection.options[:finder_sql]
|
87
|
+
@finder_sql = interpolate_sql(@reflection.options[:finder_sql])
|
88
|
+
|
89
|
+
when @reflection.options[:as]
|
90
|
+
@finder_sql =
|
91
|
+
"#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_id = #{owner_quoted_id} AND " +
|
92
|
+
"#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote_value(@owner.class.base_class.name.to_s)}"
|
93
|
+
@finder_sql << " AND (#{conditions})" if conditions
|
94
|
+
|
95
|
+
else
|
96
|
+
@finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} = #{owner_quoted_id}"
|
97
|
+
@finder_sql << " AND (#{conditions})" if conditions
|
98
|
+
end
|
99
|
+
|
100
|
+
if @reflection.options[:counter_sql]
|
101
|
+
@counter_sql = interpolate_sql(@reflection.options[:counter_sql])
|
102
|
+
elsif @reflection.options[:finder_sql]
|
103
|
+
# replace the SELECT clause with COUNT(*), preserving any hints within /* ... */
|
104
|
+
@reflection.options[:counter_sql] = @reflection.options[:finder_sql].sub(/SELECT (\/\*.*?\*\/ )?(.*)\bFROM\b/im) { "SELECT #{$1}COUNT(*) FROM" }
|
105
|
+
@counter_sql = interpolate_sql(@reflection.options[:counter_sql])
|
106
|
+
else
|
107
|
+
@counter_sql = @finder_sql
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def construct_scope
|
112
|
+
create_scoping = {}
|
113
|
+
set_belongs_to_association_for(create_scoping)
|
114
|
+
{
|
115
|
+
:find => { :conditions => @finder_sql, :readonly => false, :order => @reflection.options[:order], :limit => @reflection.options[:limit], :include => @reflection.options[:include]},
|
116
|
+
:create => create_scoping
|
117
|
+
}
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|