Skip to content

Instantly share code, notes, and snippets.

Created January 15, 2009 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/47524 to your computer and use it in GitHub Desktop.
Save anonymous/47524 to your computer and use it in GitHub Desktop.
# ===========
# odd, but Okay way to do it
opts = {:auto_validation => false}
opts_string = opts.merge({:size => 50})
opts_decimal = opts.merge({:precision => 10, :scale => 4})
property :firstname, String, opts_string
property :lastname, String, opts_string
property :minimum, BigDecimal, opts_decimal.merge({:nullable =>false})
property :maximum, BigDecimal, opts_decimal
# ===========
# cleaner
opts = {:auto_validation => false, :size => 50}
property :firstname, String, opts
property :lastname, String, opts
opts = {:auto_validation => false, :precision => 10, :scale => 4}
property :minimum, BigDecimal, opts.merge({:nullable => false})
property :maximum, BigDecimal, opts
# ===========
# more typing at first, but easier to maintain, more declarative, and more glance-able
# (Adam's preference)
property :firstname, String, :auto_validation => false, :size => 50
property :lastname, String, :auto_validation => false, :size => 50
property :minimum, BigDecimal, :auto_validation => false, :precision => 10, :scale => 4, :nullable => false
property :maximum, BigDecimal, :auto_validation => false, :precision => 10, :scale => 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment