Sha256: c667c6945e3c8b029332550efd5bdb4e9c4f2517347c9947270ac0bf17bb6486
Contents?: true
Size: 958 Bytes
Versions: 1
Compression:
Stored size: 958 Bytes
Contents
module Datagrid module Drivers class ActiveRecord < AbstractDriver def self.match?(scope) return false unless defined?(::ActiveRecord) if scope.is_a?(Class) scope.ancestors.include?(::ActiveRecord::Base) else scope.is_a?(::ActiveRecord::Relation) end end def to_scope(scope) scope.scoped({}) end def where(scope, condition) scope.where(condition) end def asc(scope, order) # Rails 3.x.x don't able to override already applied order # Using #reorder instead scope.reorder(order) end def desc(scope, order) scope.reorder(order).reverse_order end def table_name(scope) scope.table_name end def default_order(scope, column_name) scope.column_names.include?(column_name.to_s) ? [scope.table_name, column_name].join(".") : nil end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
datagrid-0.5.0 | lib/datagrid/drivers/active_record.rb |