too messy when you have sets of options
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
=====
much cleaner and easier to read with something like
with_default_options {:auto_validation => false} do
with_default_options {:size => 50} do
property :firstname, String
property :lastname, String
end
with_default_options {:precision => 10, :scale => 4} do
property :minimum, BigDecimal, :nullable => false
property :lastname, BigDecimal
end
end
On Jan 14, 3:04 pm, "Adam French" <[email protected]> wrote:
> Avoid needless complexity
> opts = {:size => (10..100), :scale =>2, :nullable => false}
> property :maximum, BigDecimal, opts
> property :minimum, BigDecimal, opts
>
> ===
> ~Adam
>
> On Wed, Jan 14, 2009 at 9:01 AM, Michael Klishin <
>
> [email protected]> wrote:
>
> > On 14.01.2009, at 17:13, heda wrote:
>
> > > I'd imagine (though Michael can verify this) that the block should
> > > look something like this
>
> > > with_default_options {:precision => 8, :scale => 2, :nullable =>
> > > false} do
> > > property :minimum, BigDecimal
> > > property :maximum, BigDecimal
> > > end
>
> > > with_default_options {:size => (10..100), :nullable => false} do
> > > property :firstname, String
> > > property :lastname, String
> > > end
>
> > Correct
>
> > MK
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---