Created
April 18, 2009 18:51
-
-
Save roidrage/97731 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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