Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
[ANN] Scoped Proxy 1.0
Kaspar Schiess
12/23/2007 6:00:00 PM
== What?
class User < ActiveRecord::Base
scoped_proxy :role do |role|
{
:find => { :conditions => ['role = ?', role] }
}
end
scoped_proxy :deleted, :find => {
:conditions => 'deleted_at is not null'
}
end
admins = User.role('admin')
admins.count # => 12
admins.find(:all) # => [ ... ]
User.deleted.count # => a number
== More!
Swiss.rb is a small project for a small country. Here we'll release all
sorts of small projects that we would not release otherwise - partly
issued by the local ruby user group, partly things we develop for
applications.
ScopedProxy is a small plugin for ActiveRecord that allows you to name
a set of sql conditions (like role('admin')) and then access it through
that name. Really the logical consequence of with_scope!
This latest version has default proxies that take effect when no other
proxy is in effect. This is quite useful for always restricting search,
not just when using a named proxy.
== Get your copy
http://rubyforge.org/frs/?gro...
or maybe
gem install ScopedProxy
== Earlier Releases
Were on my old blog neotrivium.com - now we have an official project
home (
http://rubyforge.org/projec...
), and one that isn't so
enterprisey ;) Please let us know what you think! If you have something
to contribute - please get in touch. Happy Hacking!
best greetings
Kaspar Schiess
--
(oh & please visit our new blog at labs.restorm.com)
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
[ANN] Scoped Proxy 1.0
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password