Ruby 1.9.2: explicitly raise NoMethodError for explicit coercion attempts

This commit is contained in:
Jeremy Kemper 2009-12-06 18:22:09 -08:00
parent 071af66e9e
commit 63e435955e

@ -235,6 +235,10 @@ def attribute_method_matchers #:nodoc:
# It's also possible to instantiate related objects, so a Client class belonging to the clients
# table with a +master_id+ foreign key can instantiate master through Client#master.
def method_missing(method_id, *args, &block)
if method_id == :to_ary || method_id == :to_str
raise NoMethodError, "undefined method `#{method_id}' for #{inspect}:#{self.class}"
end
method_name = method_id.to_s
if match = match_attribute_method?(method_name)
guard_private_attribute_method!(method_name, args)