Names scopes and boolean methods

Hi,

We’re exploring the new world of named scopes (hooray) and wondered
about some functionality.

If I have for example

named_scope :foo, :conditions => {:bar => true, :quux => 2}

which obviously creates a Model.foo method, would it be possible to
automatically generate a method Model#foo? which told you whether an
instance of that model was a member of the Model.foo collection?

The idea is that the named scope would let you do things like

model Article
named_scope :published, :conditions => { :some => :conditions }
end

@article = Article.published.first # for the entire model
@article.published? # for any given article

Is there any reason this wouldn’t be possible?>

Thanks,
Gareth

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs