You have Object A and Object B. You need to call a method on A, passing B as a param, to return the relationship of B to A. You'll get back answers like :owner (if A==B, or A.creator == B, or A.owner == B, or something like that), :friend (if A considers B a friend, or A is a group and B is a member, etc), or :other (if neither of the others).
If we were calling the method on B and passing A, I'd say B.relationship_to(A). But what do I call it in the other direction? A.xxx(B)? I don't like .relationship_from, 'cause that sounds kinda stupid. I'm looking for better ideas.
edit:
May as well be more concrete.
The logged in user, the person doing the browsing, is represented by 'current_profile'.
Now, if you're looking at someone else's profile, they'll be @profile. Or if you're looking at a group, it's @group. Or an event, it'll be @calendarItem (Event was taken). I'm defining an API that all three of these things share, and want to be able to say things like @profile.xxx(current_profile), instead of current_profile.relationship_to(@profile) . It's entirely an aesthetic thing, there's no strong reason for wanting it this way.
editedit:
Well, ok, that's not /strictly/ true. It's /mostly/ aesthetic. But there's also the question of the 'friend' state, which will be based on relationship objects from A, not from B. so, if I'm calling B.relationship_to(A), the function on B will end up searching thru A.friends for itself, which just Feels Weird. If the actual implementation of this function was going to be different for each of the classes, then it would /have/ to be this way, since we don't want a Profile to need to know how to find the 'friends' of an Event. But since I'm planning to implement it once, in a module they'll all include, that's not an issue.
If we were calling the method on B and passing A, I'd say B.relationship_to(A). But what do I call it in the other direction? A.xxx(B)? I don't like .relationship_from, 'cause that sounds kinda stupid. I'm looking for better ideas.
edit:
May as well be more concrete.
The logged in user, the person doing the browsing, is represented by 'current_profile'.
Now, if you're looking at someone else's profile, they'll be @profile. Or if you're looking at a group, it's @group. Or an event, it'll be @calendarItem (Event was taken). I'm defining an API that all three of these things share, and want to be able to say things like @profile.xxx(current_profile), instead of current_profile.relationship_to(@profile)
editedit:
Well, ok, that's not /strictly/ true. It's /mostly/ aesthetic. But there's also the question of the 'friend' state, which will be based on relationship objects from A, not from B. so, if I'm calling B.relationship_to(A), the function on B will end up searching thru A.friends for itself, which just Feels Weird. If the actual implementation of this function was going to be different for each of the classes, then it would /have/ to be this way, since we don't want a Profile to need to know how to find the 'friends' of an Event. But since I'm planning to implement it once, in a module they'll all include, that's not an issue.
9 commentations | Encommentate