This
commit from 2009 replaces BlankSlate with a less
invasive implementation in ActiveSupport::BasicObject.
It never got backported to 2-3-stable, but it probably should
be.
For example, the implementation of
ActiveSupport::Duration inherits from
BasicObject so that it can delegate all "other"
methods to the duration's underlying value. However,
because BlankSlate doesn't even define
#send, this causes
problems when you expect duration.foo (actually
called on duration) to behave the same as
duration.send(:foo) (delegated to
duration's underlying value):
> helper.options_from_collection_for_select([1.day, 1.month, 1.year], :to_i, :inspect)
=> "<option value=\"86400\">86400</option>\n<option value=\"2592000\">2592000</option>\n<option value=\"31557600\">31557600.0</option>"
This is obviously the sort of problem that the removal of
BlankSlate was intended to solve; indeed if you
cherry-pick
dd15a3f onto
2-3-stable, you get the expected behaviour:
> helper.options_from_collection_for_select([1.day, 1.month, 1.year], :to_i, :inspect)
=> "<option value=\"86400\">1 day</option>\n<option value=\"2592000\">1 month</option>\n<option value=\"31557600\">1 year</option>"