Skip to content

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

License

Notifications You must be signed in to change notification settings

robin/scopegroup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages