On 23/08/06, Ioana Nap <ni / arobs.ro> wrote:
> Hi,
> Can you help me please and tell how can i check if a field is read only
> in ruby?
> i'm trying to write a automated script
>
>
> Thanks
>
> --
> Posted via http://www.ruby-forum.com/.
>
>

You could check to see if the object responds to "field=".

irb(main):007:0> class Person
irb(main):008:1>   attr_reader :name
irb(main):009:1>   def initialize(name)
irb(main):010:2>     @name = name
irb(main):011:2>   end
irb(main):012:1> end
irb(main):014:0> p = Person.new("Farrel")
=> #<Person:0x2db0b48 @name="Farrel">
irb(main):015:0> p.name
=> "Farrel"
irb(main):016:0> p.respond_to?("name=")
=> false