Skip to content

Instantly share code, notes, and snippets.

Created Jan 15, 2009
Embed
What would you like to do?
# ===========
# 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