Stats
Version
0.6.3
Wheels Compatibility
1.0.3, 1.0
Downloads
276
Last Updated
April 5, 2010
About Plugins
Plugins allow you to extend or modify default Wheels application behavior. To use, you just drop the zip file into your plugins directory and reload your application.
Read Using and Creating Plugins for more information.
DefaultScope
Adds the ability to set defaults for the findAll() method on a per-Model basis.
Author
Project Home
http://github.com/illuminerdi/DefaultScope
Description
DefaultScope
The DefaultScope plugin seeks to add the functionality of Rails' ActiveRecord::Base#default_scope to Wheels. While you can use set() right now in Wheels to alter the global defaults of the findAll() method, you can't set a scope for individual models. With this plugin, you can specify default values for the findAll() method on a specific model.
This plugin overrides the findAll() method and adds a new method called defaultScope().
New Methods
- defaultScope([ where, order, select, distinct, include, maxRows, page, perPage, count, handle, cache, reload, parameterize, returnAs, returnIncluded ])
This method is mixed in to your Models and is meant to be invoked from the init() method. It takes all of the same optional arguments as the findAll() method, and will set them as defaults for future calls to that method.
Overridden Methods
- findAll()
While this method has been overridden in order to accommodate the new defaultScope settings, it still behaves the same as it did before. Use it the way you normally would. Just remember that you might have set some values in the defaultScope(). If you set new values for the same parameters here, those values will override the values set in defaultScope().
How to Use
Install it! Then the new method is automatically available to you.
Uninstallation
All you need to do is delete the /plugins/DefaultScope-x.x.zip file.
Thanks
To the rather active CFWheels Google group, and especially James Gibson who helped squirrel out an annoying bug during the initial development.
Usage/Examples
<!--- in any model --->
<cffunction name="init">
<!--- assume we have a model containing user information, and you want to sort by the last name then first for most of your findAll() requests. --->
<cfset defaultScope(order="lastName, firstName") />
</cffunction>
Change Log
Version 0.6.3—April 5, 2010 Download
- Compatibility update, through CFWheels 1.0.3
- Fixing typo in column statistics methods
- Wheels compatibility: 1.0, 1.0.3.
Version 0.6.2—December 19, 2009 Download
- 2009-12-19 -- 0.6.2
- fix for DefaultScope causing issues with the calculations methods (andybellenie)
- Wheels compatibility: 1.0, 1.0.1.
Version 0.6.1—December 9, 2009 Download
- 2009-12-09 -- 0.6.1
- code cleanup
- slight change to how the methods determine valid arguments for
findAll()anddefaultScope() - Wheels compatibility: 1.0.
- 2009-12-08 -- 0.6
- reduced loop overhead and simplified code (andybellenie)
- 2009-12-07 -- 0.5
- initial public release
- feature complete but probably bug-ridden
- 2009-12-05 -- 0.1
- happy birthday
Version 0.6—December 8, 2009 Download
- 2009-12-08 -- 0.6
- reduced loop overhead and simplified code (andybellenie)
- Wheels compatibility: 1.0.
- 2009-12-07 -- 0.5
- initial public release
- feature complete but probably bug-ridden
- 2009-12-05 -- 0.1
- happy birthday
Version 0.5—December 7, 2009 Download
- 2009-12-07 -- 0.5
- initial public release
- feature complete but probably bug-ridden
- Wheels compatibility: 1.0.
- 2009-12-05 -- 0.1
- happy birthday
