#11 ✓resolved
Justin Ossevoort

Support for 'readonly' attributes

Reported by Justin Ossevoort | June 24th, 2009 @ 01:31 PM

It would be nice if one could easily prevent the generation of the setter method. Perhaps something along the lines of Moose's 'is' property:

has :uuid, :is => :ro, :kind => UUID

(And a uuid is obviously read-only ;-))

What is the recommended way to flag a ticket as 'wish list' or 'feature' request? By using tags?

I don't necessarily want you to do all the work, but I'm flagging stuf I'm missing so that pherhaps they will be implemented, there is a nice workaround/alternative or I'll implement them myself and send a patch :-)

Comments and changes to this ticket

  • Sean O'Halpin

    Sean O'Halpin October 11th, 2009 @ 02:34 AM

    • State changed from “new” to “resolved”

    Use the :readonly option (introduced in version 0.1.9):

    require 'doodle'
    class Foo < Doodle
      counter = 0
      has :uid, :readonly => true do
        init { counter += 1 }
    bar = Foo.new
    bar.uid                         # => 1
    bar.uid = 2
    # ~> -:12: Trying to set a readonly attribute: uid (Doodle::ReadOnlyError)

    Hmmm. I've had a look at the documentation and found that :readonly is not documented. Also, it fails to protect overwriting in certain edge cases (e.g. when you use #defer_validation).

  • Sean O'Halpin

    Sean O'Halpin October 11th, 2009 @ 02:37 AM

    Regarding your other points:

    By all means tag a ticket with "feature" to denote a feature request.

    I'd welcome any patches - no promises to incorporate them though ;)

  • Justin Ossevoort

    Justin Ossevoort October 12th, 2009 @ 08:03 AM

    Ah I was wondering how to do that, I'm more used to traditional issue tracking systems which have a clear classification, but I can see how tags help to simulate this ;-)

    And great that the <:readonly> flag was already present, I guess I should have studied doodles core more ;-)

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

This site is for tracking issues for the doodle rubygem.

doodle is a Ruby gem for creating extended attribute accessors with defaults, conversions and validations.

See http://doodle.rubyforge.org/ for more details.

People watching this ticket