lib/ransack/adapters/mongoid/base.rb in ransack-1.8.2 vs lib/ransack/adapters/mongoid/base.rb in ransack-1.8.3
- old
+ new
@@ -6,10 +6,14 @@
module Base
extend ActiveSupport::Concern
included do
+ class_attribute :_ransackers
+ class_attribute :_ransack_aliases
+ self._ransackers ||= {}
+ self._ransack_aliases ||= {}
end
class ColumnWrapper < SimpleDelegator
def type
_super = super
@@ -31,35 +35,20 @@
name
end
end
module ClassMethods
- def _ransack_aliases
- @_ransack_aliases ||= {}
- end
-
- def _ransack_aliases=(value)
- @_ransack_aliases = value
- end
-
- def _ransackers
- @_ransackers ||= {}
- end
-
- def _ransackers=(value)
- @_ransackers = value
- end
-
def ransack(params = {}, options = {})
params = params.presence || {}
Search.new(self, params ? params.delete_if {
|k, v| v.blank? && v != false } : params, options)
end
alias_method :search, :ransack
def ransack_alias(new_name, old_name)
- self._ransack_aliases.store(new_name.to_s, old_name.to_s)
+ self._ransack_aliases = _ransack_aliases.merge new_name.to_s =>
+ old_name.to_s
end
def ransacker(name, opts = {}, &block)
self._ransackers = _ransackers.merge name.to_s => Ransacker
.new(self, name, opts, &block)