Trans
10/7/2008 2:32:00 PM
On Oct 7, 5:11=A0am, Pe=F1a, Botp <b...@delmonte-phil.com> wrote:
> From: Trans [mailto:transf...@gmail.com]
> #...
> # =A0 r =3D query do
> # =A0 =A0 =A0 =A0 from :c =3D> :customer, :a =3D> :account, :b =3D> :bank
> # =A0 =A0 =A0 =A0 select b.name
> # =A0 =A0 =A0 =A0 where (( c.firstname =3D=3D first1 ) |
> # =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0( c.firstname =3D=3D first2 ) ) &
> # =A0 =A0 =A0 =A0 =A0 =A0 =A0 ( c.lastname =3D~ last ) &
> # =A0 =A0 =A0 =A0 =A0 =A0 =A0 ( a.owner =3D=3D c ) &
> # =A0 =A0 =A0 =A0 =A0 =A0 =A0 ( a.bank =3D=3D b )
> # =A0 end
>
> try
>
> =A0 =A0r =3D query(customer, account, bank) =A0do |c,a,b|
> =A0 =A0 =A0 =A0 =A0select (( c.firstname =3D=3D first1 ) |
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ( c.firstname =3D=3D first2 ) ) &
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ( c.lastname =3D~ last ) &
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ( a.owner =3D=3D c ) &
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ( a.bank =3D=3D b ) .
> =A0 =A0 =A0 =A0 =A0collect b.name
> =A0 =A0 =A0 =A0end
Ah, I see. Ok, then even a little more Rubyish:
r =3D select(customer, account, bank) do |c,a,b|
(( c.firstname =3D=3D first1 ) ||
( c.firstname =3D=3D first2 )) &&
( c.lastname =3D~ last ) &&
( a.owner =3D=3D c ) &&
( a.bank =3D=3D b )
end.
collect(customer){ |b| b.name }
> #...
> # But is Ruby ultimately expressive enough? We
> # may end up adding enough new syntax
>
> i think ruby syntax is more than enough (imho). In a way, i'd like to thi=
nk like active records when it comes to databases (in mfowler's sense, not =
rails) and use ruby to implem.
How does Fowler's approach differ from Rails? I didn't know there was
an essential distinction.
T.