Skip to content

Instantly share code, notes, and snippets.

@roidrage
Created April 18, 2009 18:51
Show Gist options
  • Save roidrage/97731 to your computer and use it in GitHub Desktop.
Save roidrage/97731 to your computer and use it in GitHub Desktop.
module CouchFoo
module NamedScope
def self.included(base)
base.class_eval do
extend ClassMethods
named_scope :scoped, lambda { |scope| scope }
end
end
module ClassMethods
def named_scope(name, options = {}, &block)
# some code was here
(class << self; self end).instance_eval do
define_method name do |*args|
scopes[name].call(self, *args)
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment