Soon you'll hear the announcement that acts_as_preference is ready for download here at Ruby on Rails blog. I wanted to share a preview of the concept and hear any feedback. The current system under development is by Skiz (freenode).
What is it?
In short, acts_as_preferenced is a dynamic preference system that will be easily extendable to add alternate preferences tailored for your systems needs. It would allow for you to only need to add anything to a single table and have as many class/models with preferences as you wish.
Importance of a solid preference system
Skiz and I have been discussing the system and its importance for the community of developers who need pereference options for their community sites built in Ruby on Rails. You can think of acts_as_preferenced as a role administration tool if you'd like, however the roles are preference specifics that pertain to classes and models in the application.
Preference system example
acts_as_preference (favored, selected, exclusive, chosen, perhaps?) --schema needs-- preferrer_type - the class which has preferences preferrer_id - the object that has preferences preferenced_id - id of object that is being preferenced_type - the class which is being preferenced name - the name of the preferences value - the value of the preference value_type - boolean, string, integer (may not be needed?)
How users see it - example
Product #1 has a 'favoured' preference on eRailsbay!
User: ben has a 'exclusive' preference for Product #1.
User: tommy has the preference 'hidden' for product #54.
(for related objects) user.set_preference(profile,'hidden',true) -- Sets/Updates the profile to be hidden for the specific user. user.preference(profile,'hidden') -- returns true from the previous method example (as boolean) user.has_preference?(profile,'hidden') -- return true if a specific related preference exists user.preferences_for(profile) -- returns all preferences as a hash for a related profile user.has_preferences_for?(profile) -- returns boolean
This is just a short preview of the capabilities. Please share your experience and feedback if you have any insights or comments.