I'm finding myself writing very similar code in two places, once to define a (virtual) boolean attribute on a model, and once to define a scope to find records that match that condition. In essence,

```
scope :something, where(some_complex_conditions)

def something?
  some_complex_conditions
end

```

A simple example: I'm modelling a club membership; a `Member` pays a `Fee`, which is valid only in a certain `year`.

```
class Member < ActiveRecord::Base
  has_many :payments
  has_many :fees, :through => :payments

  scope :current, joins(:fees).merge(Fee.current)

  def current?
    fees.current.exists?
  end
end

class Fee < ActiveRecord::Base
  has_many :payments
  has_many :members, :through => :payments

  scope :current, where(:year => Time.now.year)

  def current?
    year == Time.now.year
  end
end

```

Is there a DRYer way to write a scopes that make use of virtual attributes (or, alternatively, to determine whether a model is matched by the conditions of a scope)?

I'm pretty new to Rails so please do point out if I'm doing something stupid!