Sha256: 69b8ce4f5079114f93a3d4e4fe647e63e3f0c302c0e72652b34b2c4d0be73e80
Contents?: true
Size: 941 Bytes
Versions: 1
Compression:
Stored size: 941 Bytes
Contents
module Datagrid module Drivers class Mongoid < AbstractDriver def self.match?(scope) return false unless defined?(::Mongoid) if scope.is_a?(Class) scope.ancestors.include?(::Mongoid::Document) else scope.is_a?(::Mongoid::Criteria) end end def to_scope(scope) scope.where end def where(scope, condition) scope.where(condition) end def asc(scope, order) scope.asc(order) end def desc(scope, order) scope.desc(order) end def default_order(scope, column_name) to_scope(scope).klass.fields.keys.include?(column_name.to_s) ? column_name : nil end def greater_equal(scope, field, value) scope.where(field => {"$gte" => value}) end def less_equal(scope, field, value) scope.where(field => {"$lte" => value}) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
datagrid-0.6.0 | lib/datagrid/drivers/mongoid.rb |