RubyGems Navigation menu

validate_block 0.1.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, :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 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 'validate_*' prefix on the commands inside the block _will_ work but it is not required. WARNING: There are no specs for this yet because I suck. Actually, it's because I don't properly understand how to spec a module like this so any help on that front would be appreciated.

版本列表:

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

Development 依赖关系 (2):

作者:

  • Matthew Nielsen

所有者:

SHA 256 checksum:

150fdd9144a6e7686fa3149dbb9780ab1f088b241e3b9cf3bce41a2041dc43d4

下载总次数 4,689

这个版本 1,970

Gemfile:
= 复制到剪贴板 已复制

安装:
=

许可s:

需要的 Ruby 版本:

相关链接: