Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Support for 'readonly' attributes

#11

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 ;-))

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

p.p.s.
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 :-)

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

State: resolved
Milestone: none
Assigned to: Sean O'Halpin Sean O'Halpin

Activity

  1. Sean O'Halpin
    Sean O'Halpin
    • 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 }
      end
    end
    
    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).

    October 11th, 2009 @ 02:34 AM

  2. Sean O'Halpin
    Sean O'Halpin

    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 ;)

    October 11th, 2009 @ 02:37 AM

  3. Justin Ossevoort
    Justin Ossevoort

    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 ;-)

    October 12th, 2009 @ 08:03 AM

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.