Permalink
Browse files

adding rdoc to format_url method

  • Loading branch information...
1 parent 62c1685 commit fdbeeaf6d30675f1ecd24eb351360c91e5bb35c3 @ryanb committed Nov 29, 2011
Showing with 11 additions and 1 deletion.
  1. +10 −0 lib/url_formatter/model_additions.rb
  2. +1 −1 lib/url_formatter/version.rb
@@ -1,5 +1,15 @@
module UrlFormatter
module ModelAdditions
+ # To format and validate a URL attribute, call <tt>format_url</tt>
+ # in any Active Record model class and pass it the name of an attribute.
+ #
+ # class User < ActiveRecord::Base
+ # format_url :website
+ # end
+ #
+ # This will add a <tt>before_validation</tt> callback to add "http://" to
+ # the attribute if a protocol doesn't exist already. It then validates the
+ # format of the URL.
def format_url(attribute)
before_validation do
send("#{attribute}=", UrlFormatter.format_url(send(attribute)))
@@ -1,3 +1,3 @@
module UrlFormatter
- VERSION = "0.0.1"
+ VERSION = "0.0.2.alpha"
end

0 comments on commit fdbeeaf

Please sign in to comment.