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.

Explicit slot declaration

#49

I'd like to propose a way to declare available slots explicitly, similar to DataMapper's syntax: http://datamapper.org/docs/prope... . If you go one step further, (custom) typing of properties could also be interesting to have.

On top of that you could 'freeze' the Meta definition, to disallow adding any arbitrary slots. Which makes sense when accepting data using 'params' of your favorite web framework. Off coarse this goes against some of the principles of StrokeDB, but it would be useful nonetheless. Methods like attr_protected or attr_accessible could provide an implementation for this.

Reported by ronin-14694 (at lighthouseapp) · May 3rd, 2008 @ 04:14 PM

State: new
Milestone: none
Assigned to: Yurii Rashkovskii Yurii Rashkovskii

Activity

  1. Yurii Rashkovskii
    Yurii Rashkovskii
    • Assigned user set to Yurii Rashkovskii

    May 3rd, 2008 @ 04:14 PM

  2. Sean Ouimet
    Sean Ouimet

    Explicit slot declaration is similar to validates_type_of + validates_presence_of, except default values are not accounted for.

    Some shortcut commands could make it easier to assign defaults or limit access when needed.

    Member = StrokeDB::Meta.new do 
       #allow only these slots
       #presumably existing slot types could still be used
       available_slots 'name', 'email', 'age'
    
       #assign default values if not defined
       #if no default value listed with key, nil is assumed
       #(so :age would be :age=>nil)
       default_slots :age, :status=>"newbie"
       
       #Allow no more slot types to be added (works well with above defaults setting nil first -- or could be based on all docs using the Meta).
       #My issues with this is it would make adding a new slot type (intentionally) more difficult (impossible?), whereas available_slots could be added to.
       freeze_slots
    end
    

    June 18th, 2008 @ 08:36 AM

  3. Justin Reagor
    Justin Reagor
    • Tag set to @idea, meta

    This would look even better if it resembled DataMapper's DataMapper::Resource::ClassMethods "property" method... something like this:

    Member = StrokeDB::Meta.new do

    slot :name # no default for variable storage

    slot :age, :default => 'newbie'

    slots.freeze!

    end

    There's no reason for StrokeDB to state primitives upon initialization is there? Since pretty much any value should be able to be stored in any slot?

    Just a quick question and suggestion... ;)

    July 10th, 2008 @ 06:07 AM

  4. Lisa Bowman
    Lisa Bowman

    This is what I'd love to know more about. Thank you so much for bringing this up! Hey if you're looking for furniture online you can check out ashley furniture. They have good designs or you can try genie guessing game if you're bored at home.

    June 8th, 2020 @ 04:48 PM

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.