Sha256: f2d674df9d83bc0d450707916cc51bce4277817041e22ff065690f6ba02b52c7
Contents?: true
Size: 1.01 KB
Versions: 5
Compression:
Stored size: 1.01 KB
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(nil) 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) has_column?(scope, column_name) ? 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 def has_column?(scope, column_name) to_scope(scope).klass.fields.keys.include?(column_name.to_s) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems