module Ransack::Adapters::Mongoid::Base::ClassMethods
Public Instance Methods
_ransackers()
click to toggle source
# File lib/ransack/adapters/mongoid/base.rb, line 36 def _ransackers @_ransackers ||= {} end
_ransackers=(value)
click to toggle source
# File lib/ransack/adapters/mongoid/base.rb, line 40 def _ransackers=(value) @_ransackers = value end
all_ransackable_attributes()
click to toggle source
# File lib/ransack/adapters/mongoid/base.rb, line 57 def all_ransackable_attributes ['id'] + column_names.select { |c| c != '_id' } + _ransackers.keys end
column_names()
click to toggle source
# File lib/ransack/adapters/mongoid/base.rb, line 110 def column_names @column_names ||= fields.map(&:first) end
columns()
click to toggle source
def group_by *args, &block
criteria
end
# File lib/ransack/adapters/mongoid/base.rb, line 106 def columns @columns ||= fields.map(&:second).map{ |c| ColumnWrapper.new(c) } end
columns_hash()
click to toggle source
# File lib/ransack/adapters/mongoid/base.rb, line 114 def columns_hash columns.index_by(&:name) end
custom_join_ast(*args)
click to toggle source
# File lib/ransack/adapters/mongoid/base.rb, line 90 def custom_join_ast *args [] end
first(*args)
click to toggle source
Calls superclass method
# File lib/ransack/adapters/mongoid/base.rb, line 94 def first(*args) if args.size == 0 super else self.criteria.limit(args.first) end end
joins_values(*args)
click to toggle source
imitating active record
# File lib/ransack/adapters/mongoid/base.rb, line 86 def joins_values *args [] end
ransack(params = {}, options = {})
click to toggle source
# File lib/ransack/adapters/mongoid/base.rb, line 44 def ransack(params = {}, options = {}) params = params.presence || {} Search.new(self, params ? params.delete_if { |k, v| v.blank? && v != false } : params, options) end
Also aliased as: search
ransackable_associations(auth_object = nil)
click to toggle source
# File lib/ransack/adapters/mongoid/base.rb, line 71 def ransackable_associations(auth_object = nil) reflect_on_all_associations_all.map { |a| a.name.to_s } end
ransackable_attributes(auth_object = nil)
click to toggle source
# File lib/ransack/adapters/mongoid/base.rb, line 61 def ransackable_attributes(auth_object = nil) all_ransackable_attributes end
ransackable_scopes(auth_object = nil)
click to toggle source
For overriding with a whitelist of symbols
# File lib/ransack/adapters/mongoid/base.rb, line 80 def ransackable_scopes(auth_object = nil) [] end
ransacker(name, opts = {}, &block)
click to toggle source
# File lib/ransack/adapters/mongoid/base.rb, line 52 def ransacker(name, opts = {}, &block) self._ransackers = _ransackers.merge name.to_s => Ransacker .new(self, name, opts, &block) end
ransortable_attributes(auth_object = nil)
click to toggle source
# File lib/ransack/adapters/mongoid/base.rb, line 65 def ransortable_attributes(auth_object = nil) # Here so users can overwrite the attributes # that show up in the sort_select ransackable_attributes(auth_object) end
reflect_on_all_associations_all()
click to toggle source
# File lib/ransack/adapters/mongoid/base.rb, line 75 def reflect_on_all_associations_all reflect_on_all_associations(:belongs_to, :has_one, :has_many, :embeds_many, :embedded_in) end
table()
click to toggle source
# File lib/ransack/adapters/mongoid/base.rb, line 118 def table name = ::Ransack::Adapters::Mongoid::Attributes::Attribute.new(self.criteria, :name) { :name => name } end