Sha256: 8fa46ced6a79136cb15b06d71f862aa6a29d9a7bf7299d424f8394ed62320c63
Contents?: true
Size: 615 Bytes
Versions: 60
Compression:
Stored size: 615 Bytes
Contents
# encoding: UTF-8 module MongoMapper module Plugins module Scopes 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
Version data entries
60 entries across 60 versions & 7 rubygems