diff options
author | Xavier Noria <fxn@hashref.com> | 2009-12-30 22:53:44 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2009-12-30 22:53:44 +0100 |
commit | 7f8d2cdb1715ddfaa27eed892df7ca9884e5315a (patch) | |
tree | 3d9df41dcea1a799e464c1f5f83125023ba3326d /railties/guides | |
parent | 2e59151c5fd08a2eb2b3b48f5629baa3d9dd4ab6 (diff) | |
download | rails-7f8d2cdb1715ddfaa27eed892df7ca9884e5315a.tar.gz rails-7f8d2cdb1715ddfaa27eed892df7ca9884e5315a.tar.bz2 rails-7f8d2cdb1715ddfaa27eed892df7ca9884e5315a.zip |
AS guide: documents Object#presence
Diffstat (limited to 'railties/guides')
-rw-r--r-- | railties/guides/source/active_support_core_extensions.textile | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 8ba283122d..0e4f1da7b2 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -48,6 +48,14 @@ The method +present?+ is equivalent to +!blank?+: assert @response.body.present? # same as !@response.body.blank? </ruby> +h4. +presence+ + +The +presence+ method returns its receiver if +present?+, and +nil+ otherwise. It is useful for idioms like this: + +<ruby> +host = config[:host].presence || 'localhost' +</ruby> + h4. +duplicable?+ A few fundamental objects in Ruby are singletons. For example, in the whole live of a program the integer 1 refers always to the same instance: |