Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

23 lines (21 sloc) 0.652 kb
# encoding: UTF-8
module MongoMapper
module Plugins
module Scopes
extend ActiveSupport::Concern
module ClassMethods
def scope(name, scope_options={})
scopes[name] = lambda do |*args|
result = scope_options.is_a?(Proc) ? scope_options.call(*args) : scope_options
result = self.query(result) if result.is_a?(Hash)
self.query.merge(result)
end
singleton_class.send :define_method, name, &scopes[name]
end
def scopes
read_inheritable_attribute(:scopes) || write_inheritable_attribute(:scopes, {})
end
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.