[Rails-core] Re: Feature Request - Method to differentiate between a NullRelation and Actual Relation ?

2014-01-09 Thread Shadab Ahmed
Ok let me give you more context: def process_relation(relation) return something else when relation.is_none? # do some more processing here since we know relation will return results and then return processed result end The problem is if I need to figure out whether a relation

[Rails-core] Re: Feature Request - Method to differentiate between a NullRelation and Actual Relation ?

2014-01-09 Thread Shadab Ahmed
But the thing is if you are passed a relation as method argument, how you check whether its a none relation ? It's similar to checking nil on a method argument On Monday, January 6, 2014 6:06:53 PM UTC+5:30, Yves Senn wrote: Hey, I agree with Gabriel Sobrinho. This check goes against the

Re: [Rails-core] Re: Feature Request - Method to differentiate between a NullRelation and Actual Relation ?

2014-01-09 Thread Vipul A M
Shadab, if I get you correctly you don't want to do extra processing on an object if its NullRelation, based on the fact the default value for a result from the relation would be 0/nil etc, ex: size would return 0. I don't think differentiating on the basis of this is a good idea, the basis of

[Rails-core] Re: Feature Request - Method to differentiate between a NullRelation and Actual Relation ?

2014-01-06 Thread Gabriel Sobrinho
That's the only way right now. Although, seems wrong to me check if a relation is a null relation, that's the point of null objects, you should not know that's a null object at all (may be necessary in your case but seems wrong to me). What you can do is something like `relation.empty?' which

[Rails-core] Re: Feature Request - Method to differentiate between a NullRelation and Actual Relation ?

2014-01-06 Thread Yves Senn
Hey, I agree with Gabriel Sobrinho. This check goes against the point of having a NullRelation at all. Maybe you can provide more context about your use-case and why you need that check. On Monday, January 6, 2014 7:35:56 AM UTC+1, Shadab Ahmed wrote: Hey, I am passing a relation to a