Class: ActiveAdmin::Mongoid::Adaptor::Search
- Inherits:
-
Object
- Object
- ActiveAdmin::Mongoid::Adaptor::Search
- Defined in:
- lib/active_admin/mongoid/adaptor.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#query_hash ⇒ Object
readonly
Returns the value of attribute query_hash.
-
#search_params ⇒ Object
readonly
Returns the value of attribute search_params.
Instance Method Summary collapse
-
#initialize(object, search_params = {}) ⇒ Search
constructor
A new instance of Search.
- #method_missing(method_id, *args, &block) ⇒ Object
- #respond_to?(method_id) ⇒ Boolean
Constructor Details
#initialize(object, search_params = {}) ⇒ Search
Returns a new instance of Search.
7 8 9 10 11 12 |
# File 'lib/active_admin/mongoid/adaptor.rb', line 7 def initialize(object, search_params = {}) @base = object @search_params = search_params @query_hash = get_query_hash(search_params) @query = @base.where(@query_hash) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_id, *args, &block) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/active_admin/mongoid/adaptor.rb', line 18 def method_missing(method_id, *args, &block) if is_query(method_id) @search_params[method_id.to_s] else @query.send(method_id, *args, &block) end end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
5 6 7 |
# File 'lib/active_admin/mongoid/adaptor.rb', line 5 def base @base end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
5 6 7 |
# File 'lib/active_admin/mongoid/adaptor.rb', line 5 def query @query end |
#query_hash ⇒ Object (readonly)
Returns the value of attribute query_hash.
5 6 7 |
# File 'lib/active_admin/mongoid/adaptor.rb', line 5 def query_hash @query_hash end |
#search_params ⇒ Object (readonly)
Returns the value of attribute search_params.
5 6 7 |
# File 'lib/active_admin/mongoid/adaptor.rb', line 5 def search_params @search_params end |
Instance Method Details
#respond_to?(method_id) ⇒ Boolean
14 15 16 |
# File 'lib/active_admin/mongoid/adaptor.rb', line 14 def respond_to?(method_id) @query.send(:respond_to?, method_id) end |