I have code like this
def self.find(*args)
if @@filter
with_scope :find => {:conditions => @@filter } do
super
end
else
super
end
end
def self.paginate(*args)
if @@filter
with_scope :find => {:conditions => @@filter } do
super
end
else
super
end
end
def self.related_tag_counts(*args)
if @@filter
with_scope :find => {:conditions => @@filter } do
super
end
else
super
end
end
def self.tag_counts(*args)
if @@filter
with_scope :find => {:conditions => @@filter } do
super
end
else
super
end
end
as you can see, I’m wrapping some methods with a with_scope when
@@filtter is set. This is kind of ugly. How can I DRY this code?