Permalink
Browse files

Code cleanup before pull request.

  • Loading branch information...
lukaso committed Jul 6, 2012
1 parent 02d3247 commit a93c88d489d5948a81deaffcd2b6a86661729d88
Showing with 9 additions and 17 deletions.
  1. +9 −13 lib/active_admin/mongoid/adaptor.rb
  2. +0 −4 lib/active_admin/mongoid/resource.rb
@@ -1,15 +1,7 @@
-# module Mongoid::Document
-# def method_missing(method_id, *args, &block)
-# send(:fields, args, block) if method_id == :columns_hash
-# end
-# end
-
module ActiveAdmin
module Mongoid
module Adaptor
class Search
- # include Naming
-
attr_reader :base, :query, :query_hash, :search_params
def initialize(object, search_params = {})
@@ -20,14 +12,15 @@ def initialize(object, search_params = {})
end
def respond_to?(method_id)
- query.send(:respond_to?, method_id)
+ @query.send(:respond_to?, method_id)
end
def method_missing(method_id, *args, &block)
if is_query(method_id)
- return @search_params[method_id.to_s]
+ @search_params[method_id.to_s]
+ else
+ @query.send(method_id, *args, &block)
end
- query.send(method_id, *args, &block)
end
private
@@ -44,8 +37,11 @@ def get_query_hash(search_params)
end
def mongoidify_search(k, v)
- return [get_attribute(k), Regexp.new(Regexp.escape("#{v}"), Regexp::IGNORECASE)] if k =~ /_contains$/
- [k, v]
+ if k =~ /_contains$/
+ [get_attribute(k), Regexp.new(Regexp.escape("#{v}"), Regexp::IGNORECASE)]
+ else
+ [k, v]
+ end
end
def get_attribute(k)
@@ -6,10 +6,6 @@ class ActiveAdmin::Resource
def resource_table_name
resource_class.collection_name
end
-
- # Disable filters
- # def add_default_sidebar_sections
- # end
end
ActiveAdmin::ResourceController # autoload

0 comments on commit a93c88d

Please sign in to comment.