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.
Files changed (379) hide show
  1. data/lib/gems/activerecord-2.2.2/lib/active_record/aggregations.rb +261 -0
  2. data/lib/gems/activerecord-2.2.2/lib/active_record/association_preload.rb +374 -0
  3. data/lib/gems/activerecord-2.2.2/lib/active_record/associations/association_collection.rb +453 -0
  4. data/lib/gems/activerecord-2.2.2/lib/active_record/associations/association_proxy.rb +272 -0
  5. data/lib/gems/activerecord-2.2.2/lib/active_record/associations/belongs_to_association.rb +58 -0
  6. data/lib/gems/activerecord-2.2.2/lib/active_record/associations/belongs_to_polymorphic_association.rb +49 -0
  7. data/lib/gems/activerecord-2.2.2/lib/active_record/associations/has_and_belongs_to_many_association.rb +121 -0
  8. data/lib/gems/activerecord-2.2.2/lib/active_record/associations/has_many_association.rb +121 -0
  9. data/lib/gems/activerecord-2.2.2/lib/active_record/associations/has_many_through_association.rb +256 -0
  10. data/lib/gems/activerecord-2.2.2/lib/active_record/associations/has_one_association.rb +115 -0
  11. data/lib/gems/activerecord-2.2.2/lib/active_record/associations/has_one_through_association.rb +31 -0
  12. data/lib/gems/activerecord-2.2.2/lib/active_record/associations.rb +2227 -0
  13. data/lib/gems/activerecord-2.2.2/lib/active_record/attribute_methods.rb +387 -0
  14. data/lib/gems/activerecord-2.2.2/lib/active_record/base.rb +2967 -0
  15. data/lib/gems/activerecord-2.2.2/lib/active_record/calculations.rb +299 -0
  16. data/lib/gems/activerecord-2.2.2/lib/active_record/callbacks.rb +331 -0
  17. data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb +355 -0
  18. data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb +136 -0
  19. data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb +201 -0
  20. data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb +94 -0
  21. data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/quoting.rb +69 -0
  22. data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/schema_definitions.rb +705 -0
  23. data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/schema_statements.rb +434 -0
  24. data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract_adapter.rb +210 -0
  25. data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb +585 -0
  26. data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/postgresql_adapter.rb +1065 -0
  27. data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/sqlite3_adapter.rb +34 -0
  28. data/lib/gems/activerecord-2.2.2/lib/active_record/connection_adapters/sqlite_adapter.rb +418 -0
  29. data/lib/gems/activerecord-2.2.2/lib/active_record/dirty.rb +183 -0
  30. data/lib/gems/activerecord-2.2.2/lib/active_record/dynamic_finder_match.rb +41 -0
  31. data/lib/gems/activerecord-2.2.2/lib/active_record/fixtures.rb +998 -0
  32. data/lib/gems/activerecord-2.2.2/lib/active_record/i18n_interpolation_deprecation.rb +26 -0
  33. data/lib/gems/activerecord-2.2.2/lib/active_record/locale/en.yml +54 -0
  34. data/lib/gems/activerecord-2.2.2/lib/active_record/locking/optimistic.rb +148 -0
  35. data/lib/gems/activerecord-2.2.2/lib/active_record/locking/pessimistic.rb +77 -0
  36. data/lib/gems/activerecord-2.2.2/lib/active_record/migration.rb +560 -0
  37. data/lib/gems/activerecord-2.2.2/lib/active_record/named_scope.rb +181 -0
  38. data/lib/gems/activerecord-2.2.2/lib/active_record/observer.rb +197 -0
  39. data/lib/gems/activerecord-2.2.2/lib/active_record/query_cache.rb +21 -0
  40. data/lib/gems/activerecord-2.2.2/lib/active_record/reflection.rb +307 -0
  41. data/lib/gems/activerecord-2.2.2/lib/active_record/schema.rb +51 -0
  42. data/lib/gems/activerecord-2.2.2/lib/active_record/schema_dumper.rb +177 -0
  43. data/lib/gems/activerecord-2.2.2/lib/active_record/serialization.rb +98 -0
  44. data/lib/gems/activerecord-2.2.2/lib/active_record/serializers/json_serializer.rb +80 -0
  45. data/lib/gems/activerecord-2.2.2/lib/active_record/serializers/xml_serializer.rb +338 -0
  46. data/lib/gems/activerecord-2.2.2/lib/active_record/test_case.rb +60 -0
  47. data/lib/gems/activerecord-2.2.2/lib/active_record/timestamp.rb +41 -0
  48. data/lib/gems/activerecord-2.2.2/lib/active_record/transactions.rb +185 -0
  49. data/lib/gems/activerecord-2.2.2/lib/active_record/validations.rb +1061 -0
  50. data/lib/gems/activerecord-2.2.2/lib/active_record/version.rb +9 -0
  51. data/lib/gems/activerecord-2.2.2/lib/active_record.rb +81 -0
  52. data/lib/gems/activerecord-2.2.2/lib/activerecord.rb +1 -0
  53. data/lib/gems/activesupport-2.2.2/lib/active_support/base64.rb +33 -0
  54. data/lib/gems/activesupport-2.2.2/lib/active_support/basic_object.rb +24 -0
  55. data/lib/gems/activesupport-2.2.2/lib/active_support/buffered_logger.rb +122 -0
  56. data/lib/gems/activesupport-2.2.2/lib/active_support/cache/compressed_mem_cache_store.rb +20 -0
  57. data/lib/gems/activesupport-2.2.2/lib/active_support/cache/drb_store.rb +15 -0
  58. data/lib/gems/activesupport-2.2.2/lib/active_support/cache/file_store.rb +72 -0
  59. data/lib/gems/activesupport-2.2.2/lib/active_support/cache/mem_cache_store.rb +127 -0
  60. data/lib/gems/activesupport-2.2.2/lib/active_support/cache/memory_store.rb +52 -0
  61. data/lib/gems/activesupport-2.2.2/lib/active_support/cache/synchronized_memory_store.rb +47 -0
  62. data/lib/gems/activesupport-2.2.2/lib/active_support/cache.rb +223 -0
  63. data/lib/gems/activesupport-2.2.2/lib/active_support/callbacks.rb +280 -0
  64. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array/access.rb +53 -0
  65. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array/conversions.rb +183 -0
  66. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array/extract_options.rb +20 -0
  67. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array/grouping.rb +106 -0
  68. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array/random_access.rb +12 -0
  69. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/array.rb +13 -0
  70. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/base64/encoding.rb +16 -0
  71. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/base64.rb +4 -0
  72. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/benchmark.rb +12 -0
  73. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/bigdecimal/conversions.rb +37 -0
  74. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/bigdecimal.rb +6 -0
  75. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/blank.rb +58 -0
  76. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +14 -0
  77. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/cgi.rb +5 -0
  78. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/class/attribute_accessors.rb +54 -0
  79. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/class/delegating_attributes.rb +46 -0
  80. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/class/inheritable_attributes.rb +140 -0
  81. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/class/removal.rb +50 -0
  82. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/class.rb +4 -0
  83. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date/behavior.rb +42 -0
  84. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date/calculations.rb +230 -0
  85. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date/conversions.rb +107 -0
  86. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date.rb +10 -0
  87. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date_time/calculations.rb +126 -0
  88. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date_time/conversions.rb +96 -0
  89. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/date_time.rb +12 -0
  90. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/duplicable.rb +43 -0
  91. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/enumerable.rb +107 -0
  92. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/exception.rb +41 -0
  93. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/file/atomic.rb +46 -0
  94. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/file.rb +5 -0
  95. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/float/rounding.rb +24 -0
  96. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/float/time.rb +27 -0
  97. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/float.rb +7 -0
  98. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/conversions.rb +259 -0
  99. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/deep_merge.rb +23 -0
  100. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/diff.rb +19 -0
  101. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/except.rb +25 -0
  102. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/indifferent_access.rb +137 -0
  103. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/keys.rb +52 -0
  104. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/reverse_merge.rb +35 -0
  105. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash/slice.rb +33 -0
  106. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/hash.rb +14 -0
  107. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/integer/even_odd.rb +29 -0
  108. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/integer/inflections.rb +20 -0
  109. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/integer/time.rb +45 -0
  110. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/integer.rb +9 -0
  111. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/agnostics.rb +11 -0
  112. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/daemonizing.rb +7 -0
  113. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/debugger.rb +13 -0
  114. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/reporting.rb +59 -0
  115. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel/requires.rb +24 -0
  116. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/kernel.rb +5 -0
  117. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/load_error.rb +38 -0
  118. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/logger.rb +143 -0
  119. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/aliasing.rb +74 -0
  120. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/attr_accessor_with_default.rb +31 -0
  121. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/attr_internal.rb +32 -0
  122. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/attribute_accessors.rb +58 -0
  123. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/delegation.rb +95 -0
  124. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/inclusion.rb +30 -0
  125. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/introspection.rb +90 -0
  126. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/loading.rb +23 -0
  127. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/model_naming.rb +23 -0
  128. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module/synchronization.rb +39 -0
  129. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/module.rb +23 -0
  130. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/name_error.rb +17 -0
  131. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/numeric/bytes.rb +44 -0
  132. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/numeric/conversions.rb +19 -0
  133. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/numeric/time.rb +81 -0
  134. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/numeric.rb +9 -0
  135. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object/conversions.rb +14 -0
  136. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object/extending.rb +80 -0
  137. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object/instance_variables.rb +74 -0
  138. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object/metaclass.rb +13 -0
  139. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object/misc.rb +74 -0
  140. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/object.rb +5 -0
  141. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/pathname/clean_within.rb +14 -0
  142. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/pathname.rb +7 -0
  143. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/proc.rb +12 -0
  144. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/process/daemon.rb +25 -0
  145. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/process.rb +1 -0
  146. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/range/blockless_step.rb +32 -0
  147. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/range/conversions.rb +27 -0
  148. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/range/include_range.rb +30 -0
  149. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/range/overlaps.rb +15 -0
  150. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/range.rb +11 -0
  151. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/rexml.rb +36 -0
  152. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/access.rb +82 -0
  153. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/behavior.rb +13 -0
  154. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/conversions.rb +28 -0
  155. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/filters.rb +26 -0
  156. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/inflections.rb +167 -0
  157. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/iterators.rb +21 -0
  158. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/multibyte.rb +81 -0
  159. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/starts_ends_with.rb +35 -0
  160. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string/xchar.rb +11 -0
  161. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/string.rb +22 -0
  162. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/symbol.rb +14 -0
  163. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/time/behavior.rb +13 -0
  164. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/time/calculations.rb +303 -0
  165. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/time/conversions.rb +90 -0
  166. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/time/zones.rb +86 -0
  167. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext/time.rb +42 -0
  168. data/lib/gems/activesupport-2.2.2/lib/active_support/core_ext.rb +4 -0
  169. data/lib/gems/activesupport-2.2.2/lib/active_support/dependencies.rb +621 -0
  170. data/lib/gems/activesupport-2.2.2/lib/active_support/deprecation.rb +243 -0
  171. data/lib/gems/activesupport-2.2.2/lib/active_support/duration.rb +96 -0
  172. data/lib/gems/activesupport-2.2.2/lib/active_support/gzip.rb +25 -0
  173. data/lib/gems/activesupport-2.2.2/lib/active_support/inflections.rb +55 -0
  174. data/lib/gems/activesupport-2.2.2/lib/active_support/inflector.rb +397 -0
  175. data/lib/gems/activesupport-2.2.2/lib/active_support/json/decoding.rb +63 -0
  176. data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/date.rb +21 -0
  177. data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/date_time.rb +21 -0
  178. data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/enumerable.rb +12 -0
  179. data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/false_class.rb +5 -0
  180. data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/hash.rb +47 -0
  181. data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/nil_class.rb +5 -0
  182. data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/numeric.rb +5 -0
  183. data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/object.rb +6 -0
  184. data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/regexp.rb +5 -0
  185. data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/string.rb +36 -0
  186. data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/symbol.rb +5 -0
  187. data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/time.rb +21 -0
  188. data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoders/true_class.rb +5 -0
  189. data/lib/gems/activesupport-2.2.2/lib/active_support/json/encoding.rb +37 -0
  190. data/lib/gems/activesupport-2.2.2/lib/active_support/json/variable.rb +10 -0
  191. data/lib/gems/activesupport-2.2.2/lib/active_support/json.rb +23 -0
  192. data/lib/gems/activesupport-2.2.2/lib/active_support/locale/en.yml +32 -0
  193. data/lib/gems/activesupport-2.2.2/lib/active_support/memoizable.rb +82 -0
  194. data/lib/gems/activesupport-2.2.2/lib/active_support/multibyte/chars.rb +679 -0
  195. data/lib/gems/activesupport-2.2.2/lib/active_support/multibyte/exceptions.rb +8 -0
  196. data/lib/gems/activesupport-2.2.2/lib/active_support/multibyte/unicode_database.rb +71 -0
  197. data/lib/gems/activesupport-2.2.2/lib/active_support/multibyte.rb +33 -0
  198. data/lib/gems/activesupport-2.2.2/lib/active_support/option_merger.rb +17 -0
  199. data/lib/gems/activesupport-2.2.2/lib/active_support/ordered_hash.rb +58 -0
  200. data/lib/gems/activesupport-2.2.2/lib/active_support/ordered_options.rb +19 -0
  201. data/lib/gems/activesupport-2.2.2/lib/active_support/rescuable.rb +108 -0
  202. data/lib/gems/activesupport-2.2.2/lib/active_support/secure_random.rb +197 -0
  203. data/lib/gems/activesupport-2.2.2/lib/active_support/string_inquirer.rb +21 -0
  204. data/lib/gems/activesupport-2.2.2/lib/active_support/test_case.rb +24 -0
  205. data/lib/gems/activesupport-2.2.2/lib/active_support/testing/core_ext/test/unit/assertions.rb +72 -0
  206. data/lib/gems/activesupport-2.2.2/lib/active_support/testing/core_ext/test.rb +6 -0
  207. data/lib/gems/activesupport-2.2.2/lib/active_support/testing/default.rb +9 -0
  208. data/lib/gems/activesupport-2.2.2/lib/active_support/testing/performance.rb +452 -0
  209. data/lib/gems/activesupport-2.2.2/lib/active_support/testing/setup_and_teardown.rb +120 -0
  210. data/lib/gems/activesupport-2.2.2/lib/active_support/time_with_zone.rb +328 -0
  211. data/lib/gems/activesupport-2.2.2/lib/active_support/values/time_zone.rb +403 -0
  212. data/lib/gems/activesupport-2.2.2/lib/active_support/values/unicode_tables.dat +0 -0
  213. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/blankslate.rb +113 -0
  214. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb +20 -0
  215. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/css.rb +250 -0
  216. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb +115 -0
  217. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb +139 -0
  218. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb +63 -0
  219. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder/xmlmarkup.rb +328 -0
  220. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2/builder.rb +13 -0
  221. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb +216 -0
  222. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/i18n-0.0.1/i18n/exceptions.rb +53 -0
  223. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/i18n-0.0.1/i18n.rb +194 -0
  224. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/memcache-client-1.5.1/memcache.rb +849 -0
  225. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone.rb +47 -0
  226. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/data_timezone_info.rb +228 -0
  227. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Algiers.rb +55 -0
  228. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Cairo.rb +219 -0
  229. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Casablanca.rb +40 -0
  230. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Harare.rb +18 -0
  231. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Johannesburg.rb +25 -0
  232. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Monrovia.rb +22 -0
  233. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Africa/Nairobi.rb +23 -0
  234. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +166 -0
  235. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
  236. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Bogota.rb +23 -0
  237. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Caracas.rb +23 -0
  238. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chicago.rb +283 -0
  239. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Chihuahua.rb +136 -0
  240. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Denver.rb +204 -0
  241. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Godthab.rb +161 -0
  242. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Guatemala.rb +27 -0
  243. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Halifax.rb +274 -0
  244. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Indiana/Indianapolis.rb +149 -0
  245. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Juneau.rb +194 -0
  246. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/La_Paz.rb +22 -0
  247. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Lima.rb +35 -0
  248. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Los_Angeles.rb +232 -0
  249. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mazatlan.rb +139 -0
  250. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Mexico_City.rb +144 -0
  251. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Monterrey.rb +131 -0
  252. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/New_York.rb +282 -0
  253. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Phoenix.rb +30 -0
  254. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Regina.rb +74 -0
  255. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Santiago.rb +205 -0
  256. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Sao_Paulo.rb +171 -0
  257. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/St_Johns.rb +288 -0
  258. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Tijuana.rb +196 -0
  259. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Almaty.rb +67 -0
  260. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baghdad.rb +73 -0
  261. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Baku.rb +161 -0
  262. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Bangkok.rb +20 -0
  263. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Chongqing.rb +33 -0
  264. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Colombo.rb +30 -0
  265. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Dhaka.rb +27 -0
  266. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Hong_Kong.rb +87 -0
  267. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Irkutsk.rb +165 -0
  268. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jakarta.rb +30 -0
  269. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Jerusalem.rb +163 -0
  270. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kabul.rb +20 -0
  271. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kamchatka.rb +163 -0
  272. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Karachi.rb +30 -0
  273. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Katmandu.rb +20 -0
  274. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kolkata.rb +25 -0
  275. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Krasnoyarsk.rb +163 -0
  276. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuala_Lumpur.rb +31 -0
  277. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Kuwait.rb +18 -0
  278. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Magadan.rb +163 -0
  279. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Muscat.rb +18 -0
  280. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Novosibirsk.rb +164 -0
  281. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Rangoon.rb +24 -0
  282. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Riyadh.rb +18 -0
  283. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Seoul.rb +34 -0
  284. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Shanghai.rb +35 -0
  285. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Singapore.rb +33 -0
  286. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Taipei.rb +59 -0
  287. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tashkent.rb +47 -0
  288. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tbilisi.rb +78 -0
  289. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tehran.rb +121 -0
  290. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Tokyo.rb +30 -0
  291. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Ulaanbaatar.rb +65 -0
  292. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Urumqi.rb +33 -0
  293. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Vladivostok.rb +164 -0
  294. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yakutsk.rb +163 -0
  295. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yekaterinburg.rb +165 -0
  296. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Yerevan.rb +165 -0
  297. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Azores.rb +270 -0
  298. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/Cape_Verde.rb +23 -0
  299. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Atlantic/South_Georgia.rb +18 -0
  300. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Adelaide.rb +187 -0
  301. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Brisbane.rb +35 -0
  302. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Darwin.rb +29 -0
  303. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Hobart.rb +193 -0
  304. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Melbourne.rb +185 -0
  305. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Perth.rb +37 -0
  306. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Australia/Sydney.rb +185 -0
  307. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Etc/UTC.rb +16 -0
  308. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Amsterdam.rb +228 -0
  309. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Athens.rb +185 -0
  310. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Belgrade.rb +163 -0
  311. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Berlin.rb +188 -0
  312. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bratislava.rb +13 -0
  313. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Brussels.rb +232 -0
  314. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Bucharest.rb +181 -0
  315. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Budapest.rb +197 -0
  316. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Copenhagen.rb +179 -0
  317. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Dublin.rb +276 -0
  318. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Helsinki.rb +163 -0
  319. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Istanbul.rb +218 -0
  320. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Kiev.rb +168 -0
  321. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Lisbon.rb +268 -0
  322. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Ljubljana.rb +13 -0
  323. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/London.rb +288 -0
  324. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Madrid.rb +211 -0
  325. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Minsk.rb +170 -0
  326. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Moscow.rb +181 -0
  327. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Paris.rb +232 -0
  328. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Prague.rb +187 -0
  329. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Riga.rb +176 -0
  330. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Rome.rb +215 -0
  331. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sarajevo.rb +13 -0
  332. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Skopje.rb +13 -0
  333. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Sofia.rb +173 -0
  334. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Stockholm.rb +165 -0
  335. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Tallinn.rb +172 -0
  336. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vienna.rb +183 -0
  337. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Vilnius.rb +170 -0
  338. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Warsaw.rb +212 -0
  339. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Europe/Zagreb.rb +13 -0
  340. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Auckland.rb +202 -0
  341. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Fiji.rb +23 -0
  342. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Guam.rb +22 -0
  343. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Honolulu.rb +28 -0
  344. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Majuro.rb +20 -0
  345. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Midway.rb +25 -0
  346. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Noumea.rb +25 -0
  347. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Pago_Pago.rb +26 -0
  348. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Port_Moresby.rb +20 -0
  349. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Pacific/Tongatapu.rb +27 -0
  350. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/info_timezone.rb +52 -0
  351. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone.rb +51 -0
  352. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/linked_timezone_info.rb +44 -0
  353. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/offset_rationals.rb +98 -0
  354. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/ruby_core_support.rb +56 -0
  355. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/time_or_datetime.rb +292 -0
  356. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone.rb +508 -0
  357. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_definition.rb +56 -0
  358. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_info.rb +40 -0
  359. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_offset_info.rb +94 -0
  360. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb +198 -0
  361. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_transition_info.rb +129 -0
  362. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12/tzinfo.rb +33 -0
  363. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor/xml-simple-1.0.11/xmlsimple.rb +1021 -0
  364. data/lib/gems/activesupport-2.2.2/lib/active_support/vendor.rb +34 -0
  365. data/lib/gems/activesupport-2.2.2/lib/active_support/version.rb +9 -0
  366. data/lib/gems/activesupport-2.2.2/lib/active_support/whiny_nil.rb +58 -0
  367. data/lib/gems/activesupport-2.2.2/lib/active_support.rb +61 -0
  368. data/lib/gems/activesupport-2.2.2/lib/activesupport.rb +1 -0
  369. data/lib/gems.rb +13 -0
  370. data/lib/mack-active_record/database.rb +4 -4
  371. data/lib/mack-active_record/migration_generator/migration_generator.rb +6 -2
  372. data/lib/mack-active_record/model_generator/manifest.yml +3 -3
  373. data/lib/mack-active_record/model_generator/model_generator.rb +8 -1
  374. data/lib/mack-active_record/model_generator/templates/model.rb.template +1 -1
  375. data/lib/mack-active_record/model_generator/templates/rspec.rb.template +1 -1
  376. data/lib/mack-active_record/model_generator/templates/test.rb.template +1 -1
  377. data/lib/mack-active_record.rb +3 -1
  378. data/lib/mack-active_record_tasks.rb +3 -0
  379. metadata +457 -16
@@ -0,0 +1,261 @@
1
+ module ActiveRecord
2
+ module Aggregations # :nodoc:
3
+ def self.included(base)
4
+ base.extend(ClassMethods)
5
+ end
6
+
7
+ def clear_aggregation_cache #:nodoc:
8
+ self.class.reflect_on_all_aggregations.to_a.each do |assoc|
9
+ instance_variable_set "@#{assoc.name}", nil
10
+ end unless self.new_record?
11
+ end
12
+
13
+ # Active Record implements aggregation through a macro-like class method called +composed_of+ for representing attributes
14
+ # as value objects. It expresses relationships like "Account [is] composed of Money [among other things]" or "Person [is]
15
+ # composed of [an] address". Each call to the macro adds a description of how the value objects are created from the
16
+ # attributes of the entity object (when the entity is initialized either as a new object or from finding an existing object)
17
+ # and how it can be turned back into attributes (when the entity is saved to the database). Example:
18
+ #
19
+ # class Customer < ActiveRecord::Base
20
+ # composed_of :balance, :class_name => "Money", :mapping => %w(balance amount)
21
+ # composed_of :address, :mapping => [ %w(address_street street), %w(address_city city) ]
22
+ # end
23
+ #
24
+ # The customer class now has the following methods to manipulate the value objects:
25
+ # * <tt>Customer#balance, Customer#balance=(money)</tt>
26
+ # * <tt>Customer#address, Customer#address=(address)</tt>
27
+ #
28
+ # These methods will operate with value objects like the ones described below:
29
+ #
30
+ # class Money
31
+ # include Comparable
32
+ # attr_reader :amount, :currency
33
+ # EXCHANGE_RATES = { "USD_TO_DKK" => 6 }
34
+ #
35
+ # def initialize(amount, currency = "USD")
36
+ # @amount, @currency = amount, currency
37
+ # end
38
+ #
39
+ # def exchange_to(other_currency)
40
+ # exchanged_amount = (amount * EXCHANGE_RATES["#{currency}_TO_#{other_currency}"]).floor
41
+ # Money.new(exchanged_amount, other_currency)
42
+ # end
43
+ #
44
+ # def ==(other_money)
45
+ # amount == other_money.amount && currency == other_money.currency
46
+ # end
47
+ #
48
+ # def <=>(other_money)
49
+ # if currency == other_money.currency
50
+ # amount <=> amount
51
+ # else
52
+ # amount <=> other_money.exchange_to(currency).amount
53
+ # end
54
+ # end
55
+ # end
56
+ #
57
+ # class Address
58
+ # attr_reader :street, :city
59
+ # def initialize(street, city)
60
+ # @street, @city = street, city
61
+ # end
62
+ #
63
+ # def close_to?(other_address)
64
+ # city == other_address.city
65
+ # end
66
+ #
67
+ # def ==(other_address)
68
+ # city == other_address.city && street == other_address.street
69
+ # end
70
+ # end
71
+ #
72
+ # Now it's possible to access attributes from the database through the value objects instead. If you choose to name the
73
+ # composition the same as the attribute's name, it will be the only way to access that attribute. That's the case with our
74
+ # +balance+ attribute. You interact with the value objects just like you would any other attribute, though:
75
+ #
76
+ # customer.balance = Money.new(20) # sets the Money value object and the attribute
77
+ # customer.balance # => Money value object
78
+ # customer.balance.exchange_to("DKK") # => Money.new(120, "DKK")
79
+ # customer.balance > Money.new(10) # => true
80
+ # customer.balance == Money.new(20) # => true
81
+ # customer.balance < Money.new(5) # => false
82
+ #
83
+ # Value objects can also be composed of multiple attributes, such as the case of Address. The order of the mappings will
84
+ # determine the order of the parameters. Example:
85
+ #
86
+ # customer.address_street = "Hyancintvej"
87
+ # customer.address_city = "Copenhagen"
88
+ # customer.address # => Address.new("Hyancintvej", "Copenhagen")
89
+ # customer.address = Address.new("May Street", "Chicago")
90
+ # customer.address_street # => "May Street"
91
+ # customer.address_city # => "Chicago"
92
+ #
93
+ # == Writing value objects
94
+ #
95
+ # Value objects are immutable and interchangeable objects that represent a given value, such as a Money object representing
96
+ # $5. Two Money objects both representing $5 should be equal (through methods such as <tt>==</tt> and <tt><=></tt> from Comparable if ranking
97
+ # makes sense). This is unlike entity objects where equality is determined by identity. An entity class such as Customer can
98
+ # easily have two different objects that both have an address on Hyancintvej. Entity identity is determined by object or
99
+ # relational unique identifiers (such as primary keys). Normal ActiveRecord::Base classes are entity objects.
100
+ #
101
+ # It's also important to treat the value objects as immutable. Don't allow the Money object to have its amount changed after
102
+ # creation. Create a new Money object with the new value instead. This is exemplified by the Money#exchange_to method that
103
+ # returns a new value object instead of changing its own values. Active Record won't persist value objects that have been
104
+ # changed through means other than the writer method.
105
+ #
106
+ # The immutable requirement is enforced by Active Record by freezing any object assigned as a value object. Attempting to
107
+ # change it afterwards will result in a ActiveSupport::FrozenObjectError.
108
+ #
109
+ # Read more about value objects on http://c2.com/cgi/wiki?ValueObject and on the dangers of not keeping value objects
110
+ # immutable on http://c2.com/cgi/wiki?ValueObjectsShouldBeImmutable
111
+ #
112
+ # == Custom constructors and converters
113
+ #
114
+ # By default value objects are initialized by calling the <tt>new</tt> constructor of the value class passing each of the
115
+ # mapped attributes, in the order specified by the <tt>:mapping</tt> option, as arguments. If the value class doesn't support
116
+ # this convention then +composed_of+ allows a custom constructor to be specified.
117
+ #
118
+ # When a new value is assigned to the value object the default assumption is that the new value is an instance of the value
119
+ # class. Specifying a custom converter allows the new value to be automatically converted to an instance of value class if
120
+ # necessary.
121
+ #
122
+ # For example, the NetworkResource model has +network_address+ and +cidr_range+ attributes that should be aggregated using the
123
+ # NetAddr::CIDR value class (http://netaddr.rubyforge.org). The constructor for the value class is called +create+ and it
124
+ # expects a CIDR address string as a parameter. New values can be assigned to the value object using either another
125
+ # NetAddr::CIDR object, a string or an array. The <tt>:constructor</tt> and <tt>:converter</tt> options can be used to
126
+ # meet these requirements:
127
+ #
128
+ # class NetworkResource < ActiveRecord::Base
129
+ # composed_of :cidr,
130
+ # :class_name => 'NetAddr::CIDR',
131
+ # :mapping => [ %w(network_address network), %w(cidr_range bits) ],
132
+ # :allow_nil => true,
133
+ # :constructor => Proc.new { |network_address, cidr_range| NetAddr::CIDR.create("#{network_address}/#{cidr_range}") },
134
+ # :converter => Proc.new { |value| NetAddr::CIDR.create(value.is_a?(Array) ? value.join('/') : value) }
135
+ # end
136
+ #
137
+ # # This calls the :constructor
138
+ # network_resource = NetworkResource.new(:network_address => '192.168.0.1', :cidr_range => 24)
139
+ #
140
+ # # These assignments will both use the :converter
141
+ # network_resource.cidr = [ '192.168.2.1', 8 ]
142
+ # network_resource.cidr = '192.168.0.1/24'
143
+ #
144
+ # # This assignment won't use the :converter as the value is already an instance of the value class
145
+ # network_resource.cidr = NetAddr::CIDR.create('192.168.2.1/8')
146
+ #
147
+ # # Saving and then reloading will use the :constructor on reload
148
+ # network_resource.save
149
+ # network_resource.reload
150
+ #
151
+ # == Finding records by a value object
152
+ #
153
+ # Once a +composed_of+ relationship is specified for a model, records can be loaded from the database by specifying an instance
154
+ # of the value object in the conditions hash. The following example finds all customers with +balance_amount+ equal to 20 and
155
+ # +balance_currency+ equal to "USD":
156
+ #
157
+ # Customer.find(:all, :conditions => {:balance => Money.new(20, "USD")})
158
+ #
159
+ module ClassMethods
160
+ # Adds reader and writer methods for manipulating a value object:
161
+ # <tt>composed_of :address</tt> adds <tt>address</tt> and <tt>address=(new_address)</tt> methods.
162
+ #
163
+ # Options are:
164
+ # * <tt>:class_name</tt> - Specifies the class name of the association. Use it only if that name can't be inferred
165
+ # from the part id. So <tt>composed_of :address</tt> will by default be linked to the Address class, but
166
+ # if the real class name is CompanyAddress, you'll have to specify it with this option.
167
+ # * <tt>:mapping</tt> - Specifies the mapping of entity attributes to attributes of the value object. Each mapping
168
+ # is represented as an array where the first item is the name of the entity attribute and the second item is the
169
+ # name the attribute in the value object. The order in which mappings are defined determine the order in which
170
+ # attributes are sent to the value class constructor.
171
+ # * <tt>:allow_nil</tt> - Specifies that the value object will not be instantiated when all mapped
172
+ # attributes are +nil+. Setting the value object to +nil+ has the effect of writing +nil+ to all mapped attributes.
173
+ # This defaults to +false+.
174
+ # * <tt>:constructor</tt> - A symbol specifying the name of the constructor method or a Proc that is called to
175
+ # initialize the value object. The constructor is passed all of the mapped attributes, in the order that they
176
+ # are defined in the <tt>:mapping option</tt>, as arguments and uses them to instantiate a <tt>:class_name</tt> object.
177
+ # The default is <tt>:new</tt>.
178
+ # * <tt>:converter</tt> - A symbol specifying the name of a class method of <tt>:class_name</tt> or a Proc that is
179
+ # called when a new value is assigned to the value object. The converter is passed the single value that is used
180
+ # in the assignment and is only called if the new value is not an instance of <tt>:class_name</tt>.
181
+ #
182
+ # Option examples:
183
+ # composed_of :temperature, :mapping => %w(reading celsius)
184
+ # composed_of :balance, :class_name => "Money", :mapping => %w(balance amount), :converter => Proc.new { |balance| balance.to_money }
185
+ # composed_of :address, :mapping => [ %w(address_street street), %w(address_city city) ]
186
+ # composed_of :gps_location
187
+ # composed_of :gps_location, :allow_nil => true
188
+ # composed_of :ip_address,
189
+ # :class_name => 'IPAddr',
190
+ # :mapping => %w(ip to_i),
191
+ # :constructor => Proc.new { |ip| IPAddr.new(ip, Socket::AF_INET) },
192
+ # :converter => Proc.new { |ip| ip.is_a?(Integer) ? IPAddr.new(ip, Socket::AF_INET) : IPAddr.new(ip.to_s) }
193
+ #
194
+ def composed_of(part_id, options = {}, &block)
195
+ options.assert_valid_keys(:class_name, :mapping, :allow_nil, :constructor, :converter)
196
+
197
+ name = part_id.id2name
198
+ class_name = options[:class_name] || name.camelize
199
+ mapping = options[:mapping] || [ name, name ]
200
+ mapping = [ mapping ] unless mapping.first.is_a?(Array)
201
+ allow_nil = options[:allow_nil] || false
202
+ constructor = options[:constructor] || :new
203
+ converter = options[:converter] || block
204
+
205
+ ActiveSupport::Deprecation.warn('The conversion block has been deprecated, use the :converter option instead.', caller) if block_given?
206
+
207
+ reader_method(name, class_name, mapping, allow_nil, constructor)
208
+ writer_method(name, class_name, mapping, allow_nil, converter)
209
+
210
+ create_reflection(:composed_of, part_id, options, self)
211
+ end
212
+
213
+ private
214
+ def reader_method(name, class_name, mapping, allow_nil, constructor)
215
+ module_eval do
216
+ define_method(name) do |*args|
217
+ force_reload = args.first || false
218
+ if (instance_variable_get("@#{name}").nil? || force_reload) && (!allow_nil || mapping.any? {|pair| !read_attribute(pair.first).nil? })
219
+ attrs = mapping.collect {|pair| read_attribute(pair.first)}
220
+ object = case constructor
221
+ when Symbol
222
+ class_name.constantize.send(constructor, *attrs)
223
+ when Proc, Method
224
+ constructor.call(*attrs)
225
+ else
226
+ raise ArgumentError, 'Constructor must be a symbol denoting the constructor method to call or a Proc to be invoked.'
227
+ end
228
+ instance_variable_set("@#{name}", object)
229
+ end
230
+ instance_variable_get("@#{name}")
231
+ end
232
+ end
233
+
234
+ end
235
+
236
+ def writer_method(name, class_name, mapping, allow_nil, converter)
237
+ module_eval do
238
+ define_method("#{name}=") do |part|
239
+ if part.nil? && allow_nil
240
+ mapping.each { |pair| self[pair.first] = nil }
241
+ instance_variable_set("@#{name}", nil)
242
+ else
243
+ unless part.is_a?(class_name.constantize) || converter.nil?
244
+ part = case converter
245
+ when Symbol
246
+ class_name.constantize.send(converter, part)
247
+ when Proc, Method
248
+ converter.call(part)
249
+ else
250
+ raise ArgumentError, 'Converter must be a symbol denoting the converter method to call or a Proc to be invoked.'
251
+ end
252
+ end
253
+ mapping.each { |pair| self[pair.first] = part.send(pair.last) }
254
+ instance_variable_set("@#{name}", part.freeze)
255
+ end
256
+ end
257
+ end
258
+ end
259
+ end
260
+ end
261
+ end
@@ -0,0 +1,374 @@
1
+ module ActiveRecord
2
+ # See ActiveRecord::AssociationPreload::ClassMethods for documentation.
3
+ module AssociationPreload #:nodoc:
4
+ def self.included(base)
5
+ base.extend(ClassMethods)
6
+ end
7
+
8
+ # Implements the details of eager loading of ActiveRecord associations.
9
+ # Application developers should not use this module directly.
10
+ #
11
+ # ActiveRecord::Base is extended with this module. The source code in
12
+ # ActiveRecord::Base references methods defined in this module.
13
+ #
14
+ # Note that 'eager loading' and 'preloading' are actually the same thing.
15
+ # However, there are two different eager loading strategies.
16
+ #
17
+ # The first one is by using table joins. This was only strategy available
18
+ # prior to Rails 2.1. Suppose that you have an Author model with columns
19
+ # 'name' and 'age', and a Book model with columns 'name' and 'sales'. Using
20
+ # this strategy, ActiveRecord would try to retrieve all data for an author
21
+ # and all of its books via a single query:
22
+ #
23
+ # SELECT * FROM authors
24
+ # LEFT OUTER JOIN books ON authors.id = books.id
25
+ # WHERE authors.name = 'Ken Akamatsu'
26
+ #
27
+ # However, this could result in many rows that contain redundant data. After
28
+ # having received the first row, we already have enough data to instantiate
29
+ # the Author object. In all subsequent rows, only the data for the joined
30
+ # 'books' table is useful; the joined 'authors' data is just redundant, and
31
+ # processing this redundant data takes memory and CPU time. The problem
32
+ # quickly becomes worse and worse as the level of eager loading increases
33
+ # (i.e. if ActiveRecord is to eager load the associations' assocations as
34
+ # well).
35
+ #
36
+ # The second strategy is to use multiple database queries, one for each
37
+ # level of association. Since Rails 2.1, this is the default strategy. In
38
+ # situations where a table join is necessary (e.g. when the +:conditions+
39
+ # option references an association's column), it will fallback to the table
40
+ # join strategy.
41
+ #
42
+ # See also ActiveRecord::Associations::ClassMethods, which explains eager
43
+ # loading in a more high-level (application developer-friendly) manner.
44
+ module ClassMethods
45
+ protected
46
+
47
+ # Eager loads the named associations for the given ActiveRecord record(s).
48
+ #
49
+ # In this description, 'association name' shall refer to the name passed
50
+ # to an association creation method. For example, a model that specifies
51
+ # <tt>belongs_to :author</tt>, <tt>has_many :buyers</tt> has association
52
+ # names +:author+ and +:buyers+.
53
+ #
54
+ # == Parameters
55
+ # +records+ is an array of ActiveRecord::Base. This array needs not be flat,
56
+ # i.e. +records+ itself may also contain arrays of records. In any case,
57
+ # +preload_associations+ will preload the associations all records by
58
+ # flattening +records+.
59
+ #
60
+ # +associations+ specifies one or more associations that you want to
61
+ # preload. It may be:
62
+ # - a Symbol or a String which specifies a single association name. For
63
+ # example, specifiying +:books+ allows this method to preload all books
64
+ # for an Author.
65
+ # - an Array which specifies multiple association names. This array
66
+ # is processed recursively. For example, specifying <tt>[:avatar, :books]</tt>
67
+ # allows this method to preload an author's avatar as well as all of his
68
+ # books.
69
+ # - a Hash which specifies multiple association names, as well as
70
+ # association names for the to-be-preloaded association objects. For
71
+ # example, specifying <tt>{ :author => :avatar }</tt> will preload a
72
+ # book's author, as well as that author's avatar.
73
+ #
74
+ # +:associations+ has the same format as the +:include+ option for
75
+ # <tt>ActiveRecord::Base.find</tt>. So +associations+ could look like this:
76
+ #
77
+ # :books
78
+ # [ :books, :author ]
79
+ # { :author => :avatar }
80
+ # [ :books, { :author => :avatar } ]
81
+ #
82
+ # +preload_options+ contains options that will be passed to ActiveRecord#find
83
+ # (which is called under the hood for preloading records). But it is passed
84
+ # only one level deep in the +associations+ argument, i.e. it's not passed
85
+ # to the child associations when +associations+ is a Hash.
86
+ def preload_associations(records, associations, preload_options={})
87
+ records = [records].flatten.compact.uniq
88
+ return if records.empty?
89
+ case associations
90
+ when Array then associations.each {|association| preload_associations(records, association, preload_options)}
91
+ when Symbol, String then preload_one_association(records, associations.to_sym, preload_options)
92
+ when Hash then
93
+ associations.each do |parent, child|
94
+ raise "parent must be an association name" unless parent.is_a?(String) || parent.is_a?(Symbol)
95
+ preload_associations(records, parent, preload_options)
96
+ reflection = reflections[parent]
97
+ parents = records.map {|record| record.send(reflection.name)}.flatten
98
+ unless parents.empty? || parents.first.nil?
99
+ parents.first.class.preload_associations(parents, child)
100
+ end
101
+ end
102
+ end
103
+ end
104
+
105
+ private
106
+
107
+ # Preloads a specific named association for the given records. This is
108
+ # called by +preload_associations+ as its base case.
109
+ def preload_one_association(records, association, preload_options={})
110
+ class_to_reflection = {}
111
+ # Not all records have the same class, so group then preload
112
+ # group on the reflection itself so that if various subclass share the same association then we do not split them
113
+ # unnecessarily
114
+ records.group_by {|record| class_to_reflection[record.class] ||= record.class.reflections[association]}.each do |reflection, records|
115
+ raise ConfigurationError, "Association named '#{ association }' was not found; perhaps you misspelled it?" unless reflection
116
+
117
+ # 'reflection.macro' can return 'belongs_to', 'has_many', etc. Thus,
118
+ # the following could call 'preload_belongs_to_association',
119
+ # 'preload_has_many_association', etc.
120
+ send("preload_#{reflection.macro}_association", records, reflection, preload_options)
121
+ end
122
+ end
123
+
124
+ def add_preloaded_records_to_collection(parent_records, reflection_name, associated_record)
125
+ parent_records.each do |parent_record|
126
+ association_proxy = parent_record.send(reflection_name)
127
+ association_proxy.loaded
128
+ association_proxy.target.push(*[associated_record].flatten)
129
+ end
130
+ end
131
+
132
+ def add_preloaded_record_to_collection(parent_records, reflection_name, associated_record)
133
+ parent_records.each do |parent_record|
134
+ parent_record.send("set_#{reflection_name}_target", associated_record)
135
+ end
136
+ end
137
+
138
+ def set_association_collection_records(id_to_record_map, reflection_name, associated_records, key)
139
+ associated_records.each do |associated_record|
140
+ mapped_records = id_to_record_map[associated_record[key].to_s]
141
+ add_preloaded_records_to_collection(mapped_records, reflection_name, associated_record)
142
+ end
143
+ end
144
+
145
+ def set_association_single_records(id_to_record_map, reflection_name, associated_records, key)
146
+ seen_keys = {}
147
+ associated_records.each do |associated_record|
148
+ #this is a has_one or belongs_to: there should only be one record.
149
+ #Unfortunately we can't (in portable way) ask the database for 'all records where foo_id in (x,y,z), but please
150
+ # only one row per distinct foo_id' so this where we enforce that
151
+ next if seen_keys[associated_record[key].to_s]
152
+ seen_keys[associated_record[key].to_s] = true
153
+ mapped_records = id_to_record_map[associated_record[key].to_s]
154
+ mapped_records.each do |mapped_record|
155
+ mapped_record.send("set_#{reflection_name}_target", associated_record)
156
+ end
157
+ end
158
+ end
159
+
160
+ # Given a collection of ActiveRecord objects, constructs a Hash which maps
161
+ # the objects' IDs to the relevant objects. Returns a 2-tuple
162
+ # <tt>(id_to_record_map, ids)</tt> where +id_to_record_map+ is the Hash,
163
+ # and +ids+ is an Array of record IDs.
164
+ def construct_id_map(records, primary_key=nil)
165
+ id_to_record_map = {}
166
+ ids = []
167
+ records.each do |record|
168
+ primary_key ||= record.class.primary_key
169
+ ids << record[primary_key]
170
+ mapped_records = (id_to_record_map[ids.last.to_s] ||= [])
171
+ mapped_records << record
172
+ end
173
+ ids.uniq!
174
+ return id_to_record_map, ids
175
+ end
176
+
177
+ def preload_has_and_belongs_to_many_association(records, reflection, preload_options={})
178
+ table_name = reflection.klass.quoted_table_name
179
+ id_to_record_map, ids = construct_id_map(records)
180
+ records.each {|record| record.send(reflection.name).loaded}
181
+ options = reflection.options
182
+
183
+ conditions = "t0.#{reflection.primary_key_name} #{in_or_equals_for_ids(ids)}"
184
+ conditions << append_conditions(reflection, preload_options)
185
+
186
+ associated_records = reflection.klass.find(:all, :conditions => [conditions, ids],
187
+ :include => options[:include],
188
+ :joins => "INNER JOIN #{connection.quote_table_name options[:join_table]} as t0 ON #{reflection.klass.quoted_table_name}.#{reflection.klass.primary_key} = t0.#{reflection.association_foreign_key}",
189
+ :select => "#{options[:select] || table_name+'.*'}, t0.#{reflection.primary_key_name} as the_parent_record_id",
190
+ :order => options[:order])
191
+
192
+ set_association_collection_records(id_to_record_map, reflection.name, associated_records, 'the_parent_record_id')
193
+ end
194
+
195
+ def preload_has_one_association(records, reflection, preload_options={})
196
+ return if records.first.send("loaded_#{reflection.name}?")
197
+ id_to_record_map, ids = construct_id_map(records)
198
+ options = reflection.options
199
+ records.each {|record| record.send("set_#{reflection.name}_target", nil)}
200
+ if options[:through]
201
+ through_records = preload_through_records(records, reflection, options[:through])
202
+ through_reflection = reflections[options[:through]]
203
+ through_primary_key = through_reflection.primary_key_name
204
+ unless through_records.empty?
205
+ source = reflection.source_reflection.name
206
+ through_records.first.class.preload_associations(through_records, source)
207
+ through_records.each do |through_record|
208
+ add_preloaded_record_to_collection(id_to_record_map[through_record[through_primary_key].to_s],
209
+ reflection.name, through_record.send(source))
210
+ end
211
+ end
212
+ else
213
+ set_association_single_records(id_to_record_map, reflection.name, find_associated_records(ids, reflection, preload_options), reflection.primary_key_name)
214
+ end
215
+ end
216
+
217
+ def preload_has_many_association(records, reflection, preload_options={})
218
+ return if records.first.send(reflection.name).loaded?
219
+ options = reflection.options
220
+
221
+ primary_key_name = reflection.through_reflection_primary_key_name
222
+ id_to_record_map, ids = construct_id_map(records, primary_key_name)
223
+ records.each {|record| record.send(reflection.name).loaded}
224
+
225
+ if options[:through]
226
+ through_records = preload_through_records(records, reflection, options[:through])
227
+ through_reflection = reflections[options[:through]]
228
+ unless through_records.empty?
229
+ source = reflection.source_reflection.name
230
+ through_records.first.class.preload_associations(through_records, source, options)
231
+ through_records.each do |through_record|
232
+ through_record_id = through_record[reflection.through_reflection_primary_key].to_s
233
+ add_preloaded_records_to_collection(id_to_record_map[through_record_id], reflection.name, through_record.send(source))
234
+ end
235
+ end
236
+
237
+ else
238
+ set_association_collection_records(id_to_record_map, reflection.name, find_associated_records(ids, reflection, preload_options),
239
+ reflection.primary_key_name)
240
+ end
241
+ end
242
+
243
+ def preload_through_records(records, reflection, through_association)
244
+ through_reflection = reflections[through_association]
245
+ through_primary_key = through_reflection.primary_key_name
246
+
247
+ if reflection.options[:source_type]
248
+ interface = reflection.source_reflection.options[:foreign_type]
249
+ preload_options = {:conditions => ["#{connection.quote_column_name interface} = ?", reflection.options[:source_type]]}
250
+
251
+ records.compact!
252
+ records.first.class.preload_associations(records, through_association, preload_options)
253
+
254
+ # Dont cache the association - we would only be caching a subset
255
+ through_records = []
256
+ records.each do |record|
257
+ proxy = record.send(through_association)
258
+
259
+ if proxy.respond_to?(:target)
260
+ through_records << proxy.target
261
+ proxy.reset
262
+ else # this is a has_one :through reflection
263
+ through_records << proxy if proxy
264
+ end
265
+ end
266
+ through_records.flatten!
267
+ else
268
+ records.first.class.preload_associations(records, through_association)
269
+ through_records = records.map {|record| record.send(through_association)}.flatten
270
+ end
271
+ through_records.compact!
272
+ through_records
273
+ end
274
+
275
+ def preload_belongs_to_association(records, reflection, preload_options={})
276
+ return if records.first.send("loaded_#{reflection.name}?")
277
+ options = reflection.options
278
+ primary_key_name = reflection.primary_key_name
279
+
280
+ if options[:polymorphic]
281
+ polymorph_type = options[:foreign_type]
282
+ klasses_and_ids = {}
283
+
284
+ # Construct a mapping from klass to a list of ids to load and a mapping of those ids back to their parent_records
285
+ records.each do |record|
286
+ if klass = record.send(polymorph_type)
287
+ klass_id = record.send(primary_key_name)
288
+ if klass_id
289
+ id_map = klasses_and_ids[klass] ||= {}
290
+ id_list_for_klass_id = (id_map[klass_id.to_s] ||= [])
291
+ id_list_for_klass_id << record
292
+ end
293
+ end
294
+ end
295
+ klasses_and_ids = klasses_and_ids.to_a
296
+ else
297
+ id_map = {}
298
+ records.each do |record|
299
+ key = record.send(primary_key_name)
300
+ if key
301
+ mapped_records = (id_map[key.to_s] ||= [])
302
+ mapped_records << record
303
+ end
304
+ end
305
+ klasses_and_ids = [[reflection.klass.name, id_map]]
306
+ end
307
+
308
+ klasses_and_ids.each do |klass_and_id|
309
+ klass_name, id_map = *klass_and_id
310
+ klass = klass_name.constantize
311
+
312
+ table_name = klass.quoted_table_name
313
+ primary_key = klass.primary_key
314
+ column_type = klass.columns.detect{|c| c.name == primary_key}.type
315
+ ids = id_map.keys.map do |id|
316
+ if column_type == :integer
317
+ id.to_i
318
+ elsif column_type == :float
319
+ id.to_f
320
+ else
321
+ id
322
+ end
323
+ end
324
+ conditions = "#{table_name}.#{connection.quote_column_name(primary_key)} #{in_or_equals_for_ids(ids)}"
325
+ conditions << append_conditions(reflection, preload_options)
326
+ associated_records = klass.find(:all, :conditions => [conditions, ids],
327
+ :include => options[:include],
328
+ :select => options[:select],
329
+ :joins => options[:joins],
330
+ :order => options[:order])
331
+ set_association_single_records(id_map, reflection.name, associated_records, primary_key)
332
+ end
333
+ end
334
+
335
+ def find_associated_records(ids, reflection, preload_options)
336
+ options = reflection.options
337
+ table_name = reflection.klass.quoted_table_name
338
+
339
+ if interface = reflection.options[:as]
340
+ conditions = "#{reflection.klass.quoted_table_name}.#{connection.quote_column_name "#{interface}_id"} #{in_or_equals_for_ids(ids)} and #{reflection.klass.quoted_table_name}.#{connection.quote_column_name "#{interface}_type"} = '#{self.base_class.sti_name}'"
341
+ else
342
+ foreign_key = reflection.primary_key_name
343
+ conditions = "#{reflection.klass.quoted_table_name}.#{foreign_key} #{in_or_equals_for_ids(ids)}"
344
+ end
345
+
346
+ conditions << append_conditions(reflection, preload_options)
347
+
348
+ reflection.klass.find(:all,
349
+ :select => (preload_options[:select] || options[:select] || "#{table_name}.*"),
350
+ :include => preload_options[:include] || options[:include],
351
+ :conditions => [conditions, ids],
352
+ :joins => options[:joins],
353
+ :group => preload_options[:group] || options[:group],
354
+ :order => preload_options[:order] || options[:order])
355
+ end
356
+
357
+
358
+ def interpolate_sql_for_preload(sql)
359
+ instance_eval("%@#{sql.gsub('@', '\@')}@")
360
+ end
361
+
362
+ def append_conditions(reflection, preload_options)
363
+ sql = ""
364
+ sql << " AND (#{interpolate_sql_for_preload(reflection.sanitized_conditions)})" if reflection.sanitized_conditions
365
+ sql << " AND (#{sanitize_sql preload_options[:conditions]})" if preload_options[:conditions]
366
+ sql
367
+ end
368
+
369
+ def in_or_equals_for_ids(ids)
370
+ ids.size > 1 ? "IN (?)" : "= ?"
371
+ end
372
+ end
373
+ end
374
+ end