Sha256: c42a350319f97f494ea3c1e7b199a94df1d44e9463fc7c4e5ca5c165183b5c0e
Contents?: true
Size: 454 Bytes
Versions: 325
Compression:
Stored size: 454 Bytes
Contents
class Object # A duck-type assistant method. For example, Active Support 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. def acts_like?(duck) respond_to? :"acts_like_#{duck}?" end end
Version data entries
325 entries across 281 versions & 29 rubygems