named_scope (ActiveRecord::NamedScope::ClassMethods)

    # File lib/active_record/named_scope.rb, line 85
          def named_scope(name, options = {}, &block)
            name = name.to_sym
            scopes[name] = lambda do |parent_scope, *args|
              Scope.new(parent_scope, case options
                when Hash
                  options
                when Proc
                  options.call(*args)
              end, &block)
            end
            (class << self; self end).instance_eval do
              define_method name do |*args|
                scopes[name].call(self, *args)
              end
            end
          end