public
Description: ScopeGroup is a Ruby On Rails plugin providing dynamic named_scope grouping.
Homepage:
Clone URL: git://github.com/robin/scopegroup.git
robin (author)
Wed Apr 22 07:26:59 -0700 2009
commit  106d5aca98fce79ecc14a5f37ad784db71259144
tree    ceac9da2153afaa4b3bbf076db9794fd727f79ff
parent  f7bdf5b385550251621eb3c1535e74278e30ec5b
name age message
file MIT-LICENSE Wed Apr 22 07:07:31 -0700 2009 init commit [robin]
file README.rdoc Wed Apr 22 07:26:59 -0700 2009 modify the introduction [robin]
file Rakefile Wed Apr 22 07:07:31 -0700 2009 init commit [robin]
file init.rb Wed Apr 22 07:13:55 -0700 2009 fix a typo and add installation instruction [robin]
file install.rb Wed Apr 22 07:07:31 -0700 2009 init commit [robin]
directory lib/ Loading commit data...
directory tasks/ Wed Apr 22 07:07:31 -0700 2009 init commit [robin]
directory test/ Wed Apr 22 07:07:31 -0700 2009 init commit [robin]
file uninstall.rb Wed Apr 22 07:07:31 -0700 2009 init commit [robin]
README.rdoc

ScopeGroup

ScopeGroup is a Ruby On Rails plugin providing dynamic named_scope grouping.

You can aggregate a group of named scope together during runtime and run them together only when methods like ‘find’, ‘count’, ‘average’, etc are called.

Install

  script/plugin install git://github.com/robin/scopegroup.git

Example

Suppose Post is an activerecord model:

  scope_group = ScopeGroup.new Post
  scope_group.named_scope1
  scope_group.named_scope2(1)
  scope_group.find(:all)

is equivalent to:

  Post.named_scope1.named_scope2(1)

You can also use append_scope as:

  scope_group = ScopeGroup.new Post
  scope_group.append_scope :named_scope1
  scope_group.append_scope :named_scope2, 1
  scope_group.count

, which is equivalent to:

  Post.named_scope1.named_scope2(1).count

Author

Author:Robin Lu @ IN-SRC Studio
Company Web Site:www.in-src.com

Copyright © 2009 Robin Lu @ IN-SRC Studio , released under the MIT license