This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
mcornick (author)
Wed Mar 05 12:30:19 -0800 2008
| name | age | message | |
|---|---|---|---|
| |
MIT-LICENSE | Tue Aug 21 12:53:41 -0700 2007 | [ben] |
| |
README | Tue Aug 28 05:27:15 -0700 2007 | [ben] |
| |
init.rb | Tue Aug 21 12:53:41 -0700 2007 | [ben] |
| |
install.rb | Tue Aug 21 12:53:41 -0700 2007 | [ben] |
| |
lib/ | Tue Aug 28 05:27:15 -0700 2007 | [ben] |
| |
test/ | Tue Aug 21 12:53:41 -0700 2007 | [ben] |
README
Suggestive
==========
Suggestive is a plugin designed to help get valid data for your ActiveRecord models. To use it, you define a set of
transformations to perform on your model to create valid values for an attribute. Then, when you call a
dynamically-added method on an object, you will receive either the first available value those transformations produce,
or nil if none of the pre-defined transformations generate a usable value.
Transformations must be passed as procs, though that allows everything from Proc.new {} and lambda {} to Symbol#to_proc
declarations.
Example
=======
class Person < ActiveRecord::Base
suggestions_for :username,
Proc.new {|model| model.first_name},
Proc.new {|model| model.last_name} #, etc.
end
person = Person.new :first_name => 'Bob', :last_name => 'Sully'
username = person.suggest_username # => 'Bob', if it has not yet been saved as a username, else 'Sully' if it
available, else nil
To Do
=====
- Add scoping to the uniqueness check
Copyright (c) 2007 Ben Scofield, released under the MIT license




