[ANN] Scoped Proxy 1.0

K

Kaspar Schiess

== 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/?group_id=5130

or maybe

gem install ScopedProxy

== Earlier Releases

Were on my old blog neotrivium.com - now we have an official project
home (http://rubyforge.org/projects/swissrb), 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top