From: "Michael T. Richter" Date: 2008-04-25T07:34:20+09:00 Subject: Re: This can't be right --=-ntRUo49QiP0vCgp/SvZ3 Content-Type: multipart/alternative; boundary="=-wbWi5MPSl2TQ48H0Z8ZE" --=-wbWi5MPSl2TQ48H0Z8ZE Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Thu, 2008-04-24 at 23:25 +0900, Stefan Kroes wrote: > def name > if !@name > property =3D content_properties.find_by_key('name') > if property > @name =3D property.value > else > @name =3D "" > end > else > @name > end > end Just eyeballing this: def name @name ||=3D ( property =3D content_properties.find_by_key('name') ? property.value : "" ) end This isn't tested (because I'm not planning on implementing content_properties and find_by_key and so on) so it may not work out of the box, but it should give you and idea of what to shoot for. I did test this on @name ||=3D ( a =3D nil ? a.value : "" ) as a sanity check and got the expected "". --=20 Michael T. Richter (GoogleTalk: ttmrichter@gmail.com) I'm not schooled in the science of human factors, but I suspect surprise is not an element of a robust user interface. (Chip Rosenthal) --=-wbWi5MPSl2TQ48H0Z8ZE Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Thu, 2008-04-24 at 23:25 +0900, Stefan Kroes wrote:
  def name
    if !@name
      property =3D content_properties.find_by_key('=
name')
      if property
        @name =3D property.value
      else
        @name =3D ""
      end
    else
      @name
    end
  end

Just eyeballing this:

def name
    @name ||=3D ( property =3D content_properties.find_by_ke= y('name') ? property.value : "" )
end

This isn't tested (because I'm not planning on implementing content_propert= ies and find_by_key and so on) so it may not work out of the box, but it sh= ould give you and idea of what to shoot for.  I did test this on @= name ||=3D ( a =3D nil ? a.value : "" ) as a sanity check an= d got the expected "".

--
Michael T. Richter <ttmri= chter@gmail.com> (GoogleTalk: ttmrichter@gmail.com)
I'm not schooled in the science of human factors, but I suspect surprise= is not an element of a robust user interface. (Chip Rosenthal)
--=-wbWi5MPSl2TQ48H0Z8ZE-- --=-ntRUo49QiP0vCgp/SvZ3 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQBIEKZkLqyWkKVQ54QRAi3oAKCQlMTMqAuGMVjdnPpw1TK1ZDc8BACgi+4g V9ng6Sm6ZUK5qHAtvu5ptT4= =0q5y -----END PGP SIGNATURE----- --=-ntRUo49QiP0vCgp/SvZ3--