RubyGems Navigation menu

validate_block 0.2.0

This gem allows similar ActiveRecord validates_* commands to be grouped together in blocks and pruned of repeated parameters. How often have you had a block of validation commands in an ActiveRecord object that are repeated, especially :id or :unless options? Does this look familiar? validates_presence_of :hair, :hair_color, :unless => :bald? validates_length_of :hair, :within => 3..15, :unless => :bald? validates_inclusion_of :hair_color, :in => HAIR_COLORS, :unless => bald? Instead, this gem will allow you to replace the above code with: validate_block :unless => :bald? do presence_of :hair, :hair_color length_of :hair, :within => 3..15 inclusion_of :hair_color, :in => HAIR_COLORS end ..which is a great way to DRY your :hair, don't you think? Basically, this gem 1) removes the requirement to have 'validates_' on the front of the commands and 2) passes the options on the validate_block command to each validation command inside the block. The syntax of the validation commands remains the same. Keeping the 'validates_*' prefix on the commands inside the block _will_ work but it is not required.

Gemfile:
= 複製 已複製

安裝:
=

版本列表:

  1. 0.2.0 - September 13, 2010 (6.5 KB)
  2. 0.1.0 - August 20, 2010 (6.0 KB)

Development 相依性套件 (2):

hoe >= 2.6.1
rubyforge >= 2.0.4

擁有者:

作者:

  • Matthew Nielsen

SHA 256 checksum:

687888ea159fbeed58af087692e8bf28dde53bf30651a4f7fedd3a9837528bb7

總下載次數 7,662

這個版本 4,446

License:

Ruby 版本需求:

相關連結: