[LRUG] Naming...

Jonathan Leighton turnip at turnipspatch.com
Mon May 21 11:38:29 PDT 2007


Hey all,

I'm working on a Rails plugin called "Restflection" which provides
reflection for resources (I know, the name's cheesy ;). In other words,
you can get the resource/url/path/whatever without knowing it is an
"account" as opposed to an "article". I am struggling a bit with
deciding how to expose it. I don't want to pollute the namespace by
providing a load of methods in the controller/view, so I was thinking
along these lines:

Singular:

resource_reflection.resource                  -> @account
resource_reflection.resource=                 -> @account=
resource_reflection.name                      -> "account"
...

Plural:

resources_reflection.resources                  -> @accounts
resources_reflection.resources=                 -> @accounts=
resources_reflection.name                       -> "accounts"
...

But what do you think of this?

Singular:

restflect(:member).it
restflect(:member).it = "Foo"
restflect(:member).name

Plural:

restflect(:collection).it
restflect(:collection).it = ["Foo", "Bar]
restflect(:collection).name

My main problem is exposing the actual @account(s) object -
"resource(s)" is repetition but "it" doesn't seem very descriptive. I
think maybe I like the latter better though.

Cheers

Jon




More information about the Chat mailing list