Ok, but what about

$ irb
irb(main):001:0> class Foo
irb(main):002:1> def bar
irb(main):003:2> end
irb(main):004:1> private:bar
irb(main):005:1> end
=> Foo
irb(main):006:0> Foo.new.respond_to? :bar
=> false

-Gaius

On Tue, Sep 2, 2008 at 2:21 PM, Damian Janowski
<[EMAIL PROTECTED]> wrote:
>
> On Tue, Sep 2, 2008 at 3:00 PM, Jonathan Weiss <[EMAIL PROTECTED]> wrote:
>>> This is because the definition of :respond_to? checks
>>> whether @attributes.include?(method_name), but doesn't take attribute
>>> protection into account.
>>>
>>
>> It doesn't check attributes, it checks the actual methods on the
>> object. It is independent of Rails.
>
> Well, not really. ActiveRecord does override #respond_to? to take
> attributes into account (the "actual methods" are defined lazily).
>
>>> Foo thus does not abide by the general contract of respond_to?:
>>> "respond_to?(:baz) returns true if and only if call(:baz) does not
>>> raise a NoMethodError."
>>
>>
>> Hu? Foo.new *has* a bar method. It just doesn't allow you to set it in
>> mass-assignment.
>
> I agree. The current behavior is the same as the pure-Ruby one:
>
> $ irb
> irb(main):001:0> class Foo
> irb(main):002:1> def bar
> irb(main):003:2> end
> irb(main):004:1> protected :bar
> irb(main):005:1> end
> => Foo
> irb(main):006:0> Foo.new.respond_to? :bar
> => true
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to