acts_like?(duck) Ver: 2.0.0
From: Object Version 2.0.0
Comments

A duck-type assistant method. For example, ActiveSupport extends Date to define an acts_like_date? method, and extends Time to define acts_like_time?. As a result, we can do "x.acts_like?(:time)" and "x.acts_like?(:date)" to do duck-type-safe comparisons, since classes that we want to act like Time simply need to define an acts_like_time? method.

Sourcecode
# File /Users/nshb/svn/svn.inimit.com/railsmanual.com/www/trunk/src/rails-2.0.0/activesupport/lib/active_support/core_ext/object/misc.rb, line 56
  def acts_like?(duck)
    respond_to? "acts_like_#{duck}?"
  end
Add New Note User Added Notes