activesupport 2.1.2 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activesupport might be problematic. Click here for more details.
- data/CHANGELOG +64 -5
- data/lib/active_support.rb +6 -6
- data/lib/active_support/base64.rb +13 -2
- data/lib/active_support/basic_object.rb +1 -1
- data/lib/active_support/buffered_logger.rb +15 -14
- data/lib/active_support/cache.rb +116 -40
- data/lib/active_support/cache/compressed_mem_cache_store.rb +7 -2
- data/lib/active_support/cache/file_store.rb +7 -5
- data/lib/active_support/cache/mem_cache_store.rb +48 -21
- data/lib/active_support/cache/memory_store.rb +16 -2
- data/lib/active_support/cache/synchronized_memory_store.rb +47 -0
- data/lib/active_support/callbacks.rb +14 -9
- data/lib/active_support/core_ext/array/access.rb +27 -0
- data/lib/active_support/core_ext/array/conversions.rb +12 -7
- data/lib/active_support/core_ext/array/grouping.rb +53 -10
- data/lib/active_support/core_ext/base64/encoding.rb +3 -0
- data/lib/active_support/core_ext/bigdecimal/conversions.rb +18 -22
- data/lib/active_support/core_ext/blank.rb +5 -0
- data/lib/active_support/core_ext/class/inheritable_attributes.rb +5 -5
- data/lib/active_support/core_ext/date/behavior.rb +3 -0
- data/lib/active_support/core_ext/date/calculations.rb +24 -9
- data/lib/active_support/core_ext/date_time/calculations.rb +19 -5
- data/lib/active_support/core_ext/duplicable.rb +6 -0
- data/lib/active_support/core_ext/enumerable.rb +42 -4
- data/lib/active_support/core_ext/file.rb +4 -20
- data/lib/active_support/core_ext/file/atomic.rb +46 -0
- data/lib/active_support/core_ext/float.rb +2 -0
- data/lib/active_support/core_ext/float/time.rb +27 -0
- data/lib/active_support/core_ext/hash.rb +2 -1
- data/lib/active_support/core_ext/hash/conversions.rb +1 -1
- data/lib/active_support/core_ext/hash/deep_merge.rb +23 -0
- data/lib/active_support/core_ext/hash/except.rb +1 -1
- data/lib/active_support/core_ext/hash/reverse_merge.rb +12 -5
- data/lib/active_support/core_ext/hash/slice.rb +7 -4
- data/lib/active_support/core_ext/integer.rb +2 -0
- data/lib/active_support/core_ext/integer/time.rb +45 -0
- data/lib/active_support/core_ext/kernel/debugger.rb +4 -4
- data/lib/active_support/core_ext/logger.rb +128 -1
- data/lib/active_support/core_ext/module.rb +11 -1
- data/lib/active_support/core_ext/module/aliasing.rb +71 -67
- data/lib/active_support/core_ext/module/delegation.rb +32 -1
- data/lib/active_support/core_ext/module/introspection.rb +81 -66
- data/lib/active_support/core_ext/module/model_naming.rb +8 -7
- data/lib/active_support/core_ext/module/synchronization.rb +39 -0
- data/lib/active_support/core_ext/numeric/time.rb +0 -10
- data/lib/active_support/core_ext/object.rb +1 -0
- data/lib/active_support/core_ext/object/extending.rb +29 -7
- data/lib/active_support/core_ext/object/instance_variables.rb +1 -1
- data/lib/active_support/core_ext/object/metaclass.rb +13 -0
- data/lib/active_support/core_ext/object/misc.rb +36 -21
- data/lib/active_support/core_ext/rexml.rb +2 -2
- data/lib/active_support/core_ext/string.rb +6 -2
- data/lib/active_support/core_ext/string/access.rb +5 -5
- data/lib/active_support/core_ext/string/behavior.rb +13 -0
- data/lib/active_support/core_ext/string/inflections.rb +21 -2
- data/lib/active_support/core_ext/string/multibyte.rb +81 -0
- data/lib/active_support/core_ext/time/calculations.rb +39 -12
- data/lib/active_support/core_ext/time/conversions.rb +1 -0
- data/lib/active_support/core_ext/time/zones.rb +1 -1
- data/lib/active_support/dependencies.rb +178 -110
- data/lib/active_support/deprecation.rb +24 -4
- data/lib/active_support/inflector.rb +122 -38
- data/lib/active_support/json.rb +1 -1
- data/lib/active_support/json/encoders/date.rb +9 -2
- data/lib/active_support/json/encoders/date_time.rb +9 -2
- data/lib/active_support/json/encoders/time.rb +10 -3
- data/lib/active_support/locale/en.yml +32 -0
- data/lib/active_support/memoizable.rb +82 -0
- data/lib/active_support/multibyte.rb +31 -7
- data/lib/active_support/multibyte/chars.rb +664 -122
- data/lib/active_support/multibyte/exceptions.rb +8 -0
- data/lib/active_support/multibyte/unicode_database.rb +71 -0
- data/lib/active_support/option_merger.rb +2 -10
- data/lib/active_support/ordered_hash.rb +15 -0
- data/lib/active_support/rescuable.rb +108 -0
- data/lib/active_support/secure_random.rb +197 -0
- data/lib/active_support/string_inquirer.rb +11 -1
- data/lib/active_support/test_case.rb +16 -5
- data/lib/active_support/testing/core_ext/test.rb +6 -0
- data/lib/active_support/{core_ext → testing/core_ext}/test/unit/assertions.rb +14 -6
- data/lib/active_support/testing/performance.rb +452 -0
- data/lib/active_support/testing/setup_and_teardown.rb +34 -7
- data/lib/active_support/time_with_zone.rb +66 -42
- data/lib/active_support/values/time_zone.rb +11 -4
- data/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/active_support/vendor.rb +13 -5
- data/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb +1 -1
- data/lib/active_support/vendor/i18n-0.0.1/i18n.rb +194 -0
- data/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb +216 -0
- data/lib/active_support/vendor/i18n-0.0.1/i18n/exceptions.rb +53 -0
- data/lib/active_support/vendor/{memcache-client-1.5.0 → memcache-client-1.5.1}/memcache.rb +5 -5
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/data_timezone.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/data_timezone_info.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Algiers.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Cairo.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Casablanca.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Harare.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Johannesburg.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Monrovia.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Africa/Nairobi.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +0 -0
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/America/Argentina/San_Juan.rb +86 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Bogota.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Caracas.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Chicago.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Chihuahua.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Denver.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Godthab.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Guatemala.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Halifax.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Indiana/Indianapolis.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Juneau.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/La_Paz.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Lima.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Los_Angeles.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Mazatlan.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Mexico_City.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Monterrey.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/New_York.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Phoenix.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Regina.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Santiago.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Sao_Paulo.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/St_Johns.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/America/Tijuana.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Almaty.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Baghdad.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Baku.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Bangkok.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Chongqing.rb +0 -0
- data/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/definitions/Asia/Colombo.rb +30 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Dhaka.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Hong_Kong.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Irkutsk.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Jakarta.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Jerusalem.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kabul.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kamchatka.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Karachi.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Katmandu.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kolkata.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Krasnoyarsk.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kuala_Lumpur.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Kuwait.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Magadan.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Muscat.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Novosibirsk.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Rangoon.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Riyadh.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Seoul.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Shanghai.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Singapore.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Taipei.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tashkent.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tbilisi.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tehran.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Tokyo.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Ulaanbaatar.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Urumqi.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Vladivostok.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Yakutsk.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Yekaterinburg.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Asia/Yerevan.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Atlantic/Azores.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Atlantic/Cape_Verde.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Atlantic/South_Georgia.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Adelaide.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Brisbane.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Darwin.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Hobart.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Melbourne.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Perth.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Australia/Sydney.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Etc/UTC.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Amsterdam.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Athens.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Belgrade.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Berlin.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Bratislava.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Brussels.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Bucharest.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Budapest.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Copenhagen.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Dublin.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Helsinki.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Istanbul.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Kiev.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Lisbon.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Ljubljana.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/London.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Madrid.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Minsk.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Moscow.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Paris.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Prague.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Riga.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Rome.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Sarajevo.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Skopje.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Sofia.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Stockholm.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Tallinn.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Vienna.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Vilnius.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Warsaw.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Europe/Zagreb.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Auckland.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Fiji.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Guam.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Honolulu.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Majuro.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Midway.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Noumea.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Pago_Pago.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Port_Moresby.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/definitions/Pacific/Tongatapu.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/info_timezone.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/linked_timezone.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/linked_timezone_info.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/offset_rationals.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/ruby_core_support.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/time_or_datetime.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_definition.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_info.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_offset_info.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_period.rb +0 -0
- data/lib/active_support/vendor/{tzinfo-0.3.11 → tzinfo-0.3.12}/tzinfo/timezone_transition_info.rb +0 -0
- data/lib/active_support/vendor/xml-simple-1.0.11/xmlsimple.rb +3 -3
- data/lib/active_support/version.rb +1 -1
- metadata +185 -167
- data/lib/active_support/clean_logger.rb +0 -127
- data/lib/active_support/core_ext/string/unicode.rb +0 -66
- data/lib/active_support/core_ext/test.rb +0 -1
- data/lib/active_support/multibyte/generators/generate_tables.rb +0 -149
- data/lib/active_support/multibyte/handlers/passthru_handler.rb +0 -9
- data/lib/active_support/multibyte/handlers/utf8_handler.rb +0 -564
- data/lib/active_support/multibyte/handlers/utf8_handler_proc.rb +0 -43
- data/lib/active_support/vendor/tzinfo-0.3.11/tzinfo/definitions/America/Argentina/San_Juan.rb +0 -170
@@ -1,10 +1,11 @@
|
|
1
|
-
%w(keys indifferent_access reverse_merge conversions diff slice except).each do |ext|
|
1
|
+
%w(keys indifferent_access deep_merge reverse_merge conversions diff slice except).each do |ext|
|
2
2
|
require "active_support/core_ext/hash/#{ext}"
|
3
3
|
end
|
4
4
|
|
5
5
|
class Hash #:nodoc:
|
6
6
|
include ActiveSupport::CoreExtensions::Hash::Keys
|
7
7
|
include ActiveSupport::CoreExtensions::Hash::IndifferentAccess
|
8
|
+
include ActiveSupport::CoreExtensions::Hash::DeepMerge
|
8
9
|
include ActiveSupport::CoreExtensions::Hash::ReverseMerge
|
9
10
|
include ActiveSupport::CoreExtensions::Hash::Conversions
|
10
11
|
include ActiveSupport::CoreExtensions::Hash::Diff
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ActiveSupport #:nodoc:
|
2
|
+
module CoreExtensions #:nodoc:
|
3
|
+
module Hash #:nodoc:
|
4
|
+
# Allows for deep merging
|
5
|
+
module DeepMerge
|
6
|
+
# Returns a new hash with +self+ and +other_hash+ merged recursively.
|
7
|
+
def deep_merge(other_hash)
|
8
|
+
self.merge(other_hash) do |key, oldval, newval|
|
9
|
+
oldval = oldval.to_hash if oldval.respond_to?(:to_hash)
|
10
|
+
newval = newval.to_hash if newval.respond_to?(:to_hash)
|
11
|
+
oldval.class.to_s == 'Hash' && newval.class.to_s == 'Hash' ? oldval.deep_merge(newval) : newval
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Returns a new hash with +self+ and +other_hash+ merged recursively.
|
16
|
+
# Modifies the receiver in place.
|
17
|
+
def deep_merge!(other_hash)
|
18
|
+
replace(deep_merge(other_hash))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -13,7 +13,7 @@ module ActiveSupport #:nodoc:
|
|
13
13
|
dup.except!(*keys)
|
14
14
|
end
|
15
15
|
|
16
|
-
# Replaces the hash without
|
16
|
+
# Replaces the hash without the given keys.
|
17
17
|
def except!(*keys)
|
18
18
|
keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
|
19
19
|
keys.each { |key| delete(key) }
|
@@ -1,21 +1,28 @@
|
|
1
1
|
module ActiveSupport #:nodoc:
|
2
2
|
module CoreExtensions #:nodoc:
|
3
3
|
module Hash #:nodoc:
|
4
|
-
# Allows for reverse merging where
|
5
|
-
# This is particularly useful for initializing an
|
4
|
+
# Allows for reverse merging two hashes where the keys in the calling hash take precedence over those
|
5
|
+
# in the <tt>other_hash</tt>. This is particularly useful for initializing an option hash with default values:
|
6
6
|
#
|
7
7
|
# def setup(options = {})
|
8
8
|
# options.reverse_merge! :size => 25, :velocity => 10
|
9
9
|
# end
|
10
10
|
#
|
11
|
-
#
|
11
|
+
# Using <tt>merge</tt>, the above example would look as follows:
|
12
|
+
#
|
13
|
+
# def setup(options = {})
|
14
|
+
# { :size => 25, :velocity => 10 }.merge(options)
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# The default <tt>:size</tt> and <tt>:velocity</tt> are only set if the +options+ hash passed in doesn't already
|
18
|
+
# have the respective key.
|
12
19
|
module ReverseMerge
|
13
|
-
# Performs the opposite of merge
|
20
|
+
# Performs the opposite of <tt>merge</tt>, with the keys and values from the first hash taking precedence over the second.
|
14
21
|
def reverse_merge(other_hash)
|
15
22
|
other_hash.merge(self)
|
16
23
|
end
|
17
24
|
|
18
|
-
# Performs the opposite of merge
|
25
|
+
# Performs the opposite of <tt>merge</tt>, with the keys and values from the first hash taking precedence over the second.
|
19
26
|
# Modifies the receiver in place.
|
20
27
|
def reverse_merge!(other_hash)
|
21
28
|
replace(reverse_merge(other_hash))
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'set'
|
2
|
-
|
3
1
|
module ActiveSupport #:nodoc:
|
4
2
|
module CoreExtensions #:nodoc:
|
5
3
|
module Hash #:nodoc:
|
@@ -11,12 +9,17 @@ module ActiveSupport #:nodoc:
|
|
11
9
|
# end
|
12
10
|
#
|
13
11
|
# search(options.slice(:mass, :velocity, :time))
|
12
|
+
#
|
13
|
+
# If you have an array of keys you want to limit to, you should splat them:
|
14
|
+
#
|
15
|
+
# valid_keys = [:mass, :velocity, :time]
|
16
|
+
# search(options.slice(*valid_keys))
|
14
17
|
module Slice
|
15
18
|
# Returns a new hash with only the given keys.
|
16
19
|
def slice(*keys)
|
17
|
-
|
20
|
+
keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
|
18
21
|
hash = self.class.new
|
19
|
-
|
22
|
+
keys.each { |k| hash[k] = self[k] if has_key?(k) }
|
20
23
|
hash
|
21
24
|
end
|
22
25
|
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'active_support/core_ext/integer/even_odd'
|
2
2
|
require 'active_support/core_ext/integer/inflections'
|
3
|
+
require 'active_support/core_ext/integer/time'
|
3
4
|
|
4
5
|
class Integer #:nodoc:
|
5
6
|
include ActiveSupport::CoreExtensions::Integer::EvenOdd
|
6
7
|
include ActiveSupport::CoreExtensions::Integer::Inflections
|
8
|
+
include ActiveSupport::CoreExtensions::Integer::Time
|
7
9
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module ActiveSupport #:nodoc:
|
2
|
+
module CoreExtensions #:nodoc:
|
3
|
+
module Integer #:nodoc:
|
4
|
+
# Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years.
|
5
|
+
#
|
6
|
+
# These methods use Time#advance for precise date calculations when using from_now, ago, etc.
|
7
|
+
# as well as adding or subtracting their results from a Time object. For example:
|
8
|
+
#
|
9
|
+
# # equivalent to Time.now.advance(:months => 1)
|
10
|
+
# 1.month.from_now
|
11
|
+
#
|
12
|
+
# # equivalent to Time.now.advance(:years => 2)
|
13
|
+
# 2.years.from_now
|
14
|
+
#
|
15
|
+
# # equivalent to Time.now.advance(:months => 4, :years => 5)
|
16
|
+
# (4.months + 5.years).from_now
|
17
|
+
#
|
18
|
+
# While these methods provide precise calculation when used as in the examples above, care
|
19
|
+
# should be taken to note that this is not true if the result of `months', `years', etc is
|
20
|
+
# converted before use:
|
21
|
+
#
|
22
|
+
# # equivalent to 30.days.to_i.from_now
|
23
|
+
# 1.month.to_i.from_now
|
24
|
+
#
|
25
|
+
# # equivalent to 365.25.days.to_f.from_now
|
26
|
+
# 1.year.to_f.from_now
|
27
|
+
#
|
28
|
+
# In such cases, Ruby's core
|
29
|
+
# Date[http://stdlib.rubyonrails.org/libdoc/date/rdoc/index.html] and
|
30
|
+
# Time[http://stdlib.rubyonrails.org/libdoc/time/rdoc/index.html] should be used for precision
|
31
|
+
# date and time arithmetic
|
32
|
+
module Time
|
33
|
+
def months
|
34
|
+
ActiveSupport::Duration.new(self * 30.days, [[:months, self]])
|
35
|
+
end
|
36
|
+
alias :month :months
|
37
|
+
|
38
|
+
def years
|
39
|
+
ActiveSupport::Duration.new(self * 365.25.days, [[:years, self]])
|
40
|
+
end
|
41
|
+
alias :year :years
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -2,12 +2,12 @@ module Kernel
|
|
2
2
|
unless respond_to?(:debugger)
|
3
3
|
# Starts a debugging session if ruby-debug has been loaded (call script/server --debugger to do load it).
|
4
4
|
def debugger
|
5
|
-
|
5
|
+
Rails.logger.info "\n***** Debugger requested, but was not available: Start server with --debugger to enable *****\n"
|
6
6
|
end
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def breakpoint
|
10
|
-
|
10
|
+
Rails.logger.info "\n***** The 'breakpoint' command has been renamed 'debugger' -- please change *****\n"
|
11
11
|
debugger
|
12
12
|
end
|
13
|
-
end
|
13
|
+
end
|
@@ -12,5 +12,132 @@ class Logger
|
|
12
12
|
end_eval
|
13
13
|
end
|
14
14
|
[:debug, :info, :error, :fatal].each {|level| define_around_helper(level) }
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
+
|
18
|
+
require 'logger'
|
19
|
+
|
20
|
+
# Extensions to the built in Ruby logger.
|
21
|
+
#
|
22
|
+
# If you want to use the default log formatter as defined in the Ruby core, then you
|
23
|
+
# will need to set the formatter for the logger as in:
|
24
|
+
#
|
25
|
+
# logger.formatter = Formatter.new
|
26
|
+
#
|
27
|
+
# You can then specify the datetime format, for example:
|
28
|
+
#
|
29
|
+
# logger.datetime_format = "%Y-%m-%d"
|
30
|
+
#
|
31
|
+
# Note: This logger is deprecated in favor of ActiveSupport::BufferedLogger
|
32
|
+
class Logger
|
33
|
+
# Set to false to disable the silencer
|
34
|
+
cattr_accessor :silencer
|
35
|
+
self.silencer = true
|
36
|
+
|
37
|
+
# Silences the logger for the duration of the block.
|
38
|
+
def silence(temporary_level = Logger::ERROR)
|
39
|
+
if silencer
|
40
|
+
begin
|
41
|
+
old_logger_level, self.level = level, temporary_level
|
42
|
+
yield self
|
43
|
+
ensure
|
44
|
+
self.level = old_logger_level
|
45
|
+
end
|
46
|
+
else
|
47
|
+
yield self
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
alias :old_datetime_format= :datetime_format=
|
52
|
+
# Logging date-time format (string passed to +strftime+). Ignored if the formatter
|
53
|
+
# does not respond to datetime_format=.
|
54
|
+
def datetime_format=(datetime_format)
|
55
|
+
formatter.datetime_format = datetime_format if formatter.respond_to?(:datetime_format=)
|
56
|
+
end
|
57
|
+
|
58
|
+
alias :old_datetime_format :datetime_format
|
59
|
+
# Get the logging datetime format. Returns nil if the formatter does not support
|
60
|
+
# datetime formatting.
|
61
|
+
def datetime_format
|
62
|
+
formatter.datetime_format if formatter.respond_to?(:datetime_format)
|
63
|
+
end
|
64
|
+
|
65
|
+
alias :old_formatter :formatter if method_defined?(:formatter)
|
66
|
+
# Get the current formatter. The default formatter is a SimpleFormatter which only
|
67
|
+
# displays the log message
|
68
|
+
def formatter
|
69
|
+
@formatter ||= SimpleFormatter.new
|
70
|
+
end
|
71
|
+
|
72
|
+
unless const_defined? :Formatter
|
73
|
+
class Formatter
|
74
|
+
Format = "%s, [%s#%d] %5s -- %s: %s\n"
|
75
|
+
|
76
|
+
attr_accessor :datetime_format
|
77
|
+
|
78
|
+
def initialize
|
79
|
+
@datetime_format = nil
|
80
|
+
end
|
81
|
+
|
82
|
+
def call(severity, time, progname, msg)
|
83
|
+
Format % [severity[0..0], format_datetime(time), $$, severity, progname,
|
84
|
+
msg2str(msg)]
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
def format_datetime(time)
|
89
|
+
if @datetime_format.nil?
|
90
|
+
time.strftime("%Y-%m-%dT%H:%M:%S.") << "%06d " % time.usec
|
91
|
+
else
|
92
|
+
time.strftime(@datetime_format)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def msg2str(msg)
|
97
|
+
case msg
|
98
|
+
when ::String
|
99
|
+
msg
|
100
|
+
when ::Exception
|
101
|
+
"#{ msg.message } (#{ msg.class })\n" <<
|
102
|
+
(msg.backtrace || []).join("\n")
|
103
|
+
else
|
104
|
+
msg.inspect
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# Simple formatter which only displays the message.
|
111
|
+
class SimpleFormatter < Logger::Formatter
|
112
|
+
# This method is invoked when a log event occurs
|
113
|
+
def call(severity, timestamp, progname, msg)
|
114
|
+
"#{String === msg ? msg : msg.inspect}\n"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
private
|
119
|
+
alias old_format_message format_message
|
120
|
+
|
121
|
+
# Ruby 1.8.3 transposed the msg and progname arguments to format_message.
|
122
|
+
# We can't test RUBY_VERSION because some distributions don't keep Ruby
|
123
|
+
# and its standard library in sync, leading to installations of Ruby 1.8.2
|
124
|
+
# with Logger from 1.8.3 and vice versa.
|
125
|
+
if method_defined?(:formatter=)
|
126
|
+
def format_message(severity, timestamp, progname, msg)
|
127
|
+
formatter.call(severity, timestamp, progname, msg)
|
128
|
+
end
|
129
|
+
else
|
130
|
+
def format_message(severity, timestamp, msg, progname)
|
131
|
+
formatter.call(severity, timestamp, progname, msg)
|
132
|
+
end
|
133
|
+
|
134
|
+
attr_writer :formatter
|
135
|
+
public :formatter=
|
136
|
+
|
137
|
+
alias old_format_datetime format_datetime
|
138
|
+
def format_datetime(datetime) datetime end
|
139
|
+
|
140
|
+
alias old_msg2str msg2str
|
141
|
+
def msg2str(msg) msg end
|
142
|
+
end
|
143
|
+
end
|
@@ -7,7 +7,17 @@ require 'active_support/core_ext/module/introspection'
|
|
7
7
|
require 'active_support/core_ext/module/loading'
|
8
8
|
require 'active_support/core_ext/module/aliasing'
|
9
9
|
require 'active_support/core_ext/module/model_naming'
|
10
|
+
require 'active_support/core_ext/module/synchronization'
|
11
|
+
|
12
|
+
module ActiveSupport
|
13
|
+
module CoreExtensions
|
14
|
+
# Various extensions for the Ruby core Module class.
|
15
|
+
module Module
|
16
|
+
# Nothing here. Only defined for API documentation purposes.
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
10
20
|
|
11
21
|
class Module
|
12
|
-
include ActiveSupport::
|
22
|
+
include ActiveSupport::CoreExtensions::Module
|
13
23
|
end
|
@@ -1,70 +1,74 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
alias_method target, with_method
|
33
|
-
|
34
|
-
case
|
35
|
-
when public_method_defined?(without_method)
|
36
|
-
public target
|
37
|
-
when protected_method_defined?(without_method)
|
38
|
-
protected target
|
39
|
-
when private_method_defined?(without_method)
|
40
|
-
private target
|
41
|
-
end
|
42
|
-
end
|
1
|
+
module ActiveSupport
|
2
|
+
module CoreExtensions
|
3
|
+
module Module
|
4
|
+
# Encapsulates the common pattern of:
|
5
|
+
#
|
6
|
+
# alias_method :foo_without_feature, :foo
|
7
|
+
# alias_method :foo, :foo_with_feature
|
8
|
+
#
|
9
|
+
# With this, you simply do:
|
10
|
+
#
|
11
|
+
# alias_method_chain :foo, :feature
|
12
|
+
#
|
13
|
+
# And both aliases are set up for you.
|
14
|
+
#
|
15
|
+
# Query and bang methods (foo?, foo!) keep the same punctuation:
|
16
|
+
#
|
17
|
+
# alias_method_chain :foo?, :feature
|
18
|
+
#
|
19
|
+
# is equivalent to
|
20
|
+
#
|
21
|
+
# alias_method :foo_without_feature?, :foo?
|
22
|
+
# alias_method :foo?, :foo_with_feature?
|
23
|
+
#
|
24
|
+
# so you can safely chain foo, foo?, and foo! with the same feature.
|
25
|
+
def alias_method_chain(target, feature)
|
26
|
+
# Strip out punctuation on predicates or bang methods since
|
27
|
+
# e.g. target?_without_feature is not a valid method name.
|
28
|
+
aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1
|
29
|
+
yield(aliased_target, punctuation) if block_given?
|
30
|
+
|
31
|
+
with_method, without_method = "#{aliased_target}_with_#{feature}#{punctuation}", "#{aliased_target}_without_#{feature}#{punctuation}"
|
43
32
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
33
|
+
alias_method without_method, target
|
34
|
+
alias_method target, with_method
|
35
|
+
|
36
|
+
case
|
37
|
+
when public_method_defined?(without_method)
|
38
|
+
public target
|
39
|
+
when protected_method_defined?(without_method)
|
40
|
+
protected target
|
41
|
+
when private_method_defined?(without_method)
|
42
|
+
private target
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Allows you to make aliases for attributes, which includes
|
47
|
+
# getter, setter, and query methods.
|
48
|
+
#
|
49
|
+
# Example:
|
50
|
+
#
|
51
|
+
# class Content < ActiveRecord::Base
|
52
|
+
# # has a title attribute
|
53
|
+
# end
|
54
|
+
#
|
55
|
+
# class Email < Content
|
56
|
+
# alias_attribute :subject, :title
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
# e = Email.find(1)
|
60
|
+
# e.title # => "Superstars"
|
61
|
+
# e.subject # => "Superstars"
|
62
|
+
# e.subject? # => true
|
63
|
+
# e.subject = "Megastars"
|
64
|
+
# e.title # => "Megastars"
|
65
|
+
def alias_attribute(new_name, old_name)
|
66
|
+
module_eval <<-STR, __FILE__, __LINE__+1
|
67
|
+
def #{new_name}; self.#{old_name}; end
|
68
|
+
def #{new_name}?; self.#{old_name}?; end
|
69
|
+
def #{new_name}=(v); self.#{old_name} = v; end
|
70
|
+
STR
|
71
|
+
end
|
72
|
+
end
|
69
73
|
end
|
70
74
|
end
|