Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix requires and types

  • Loading branch information...
commit 2fc4ce2cfd5da3acc805b513b5982364860ad4c0 1 parent 68ee541
@elia elia authored
View
9 lib/active_admin-mongoid.rb
@@ -1,8 +1 @@
-require 'active_admin/mongoid/version'
-
-require 'active_admin'
-require 'active_admin/resource_controller'
-require 'active_admin/mongoid/form_builder'
-
-module ActiveAdmin::Mongoid
-end
+require 'active_admin/mongoid'
View
22 lib/active_admin/mongoid.rb
@@ -1,8 +1,20 @@
require 'active_admin'
-require 'active_admin/mongoid/comments'
-require 'active_admin/mongoid/form_builder'
-require 'active_admin/mongoid/resource'
-require 'active_admin/mongoid/document'
-module ActiveAdmin::Mongoid
+module ActiveAdmin
+ module Mongoid
+ end
+
+ class << self
+ alias setup_without_mongoid setup
+
+ # Load monkey patches *after* the setup process
+ def setup *args, &block
+ setup_without_mongoid *args, &block
+
+ require 'active_admin/mongoid/comments'
+ require 'active_admin/mongoid/form_builder'
+ require 'active_admin/mongoid/resource'
+ require 'active_admin/mongoid/document'
+ end
+ end
end
View
3  lib/active_admin/mongoid/comments.rb
@@ -1,4 +1,5 @@
-module ActiveAdmin::Namespace
+ActiveAdmin::Namespace # autoload
+class ActiveAdmin::Namespace
# Disable comments
def comments?
false
View
2  lib/active_admin/mongoid/document.rb
@@ -1,3 +1,5 @@
+require 'mongoid'
+
module ActiveAdmin::Mongoid::Document
extend ActiveSupport::Concern
View
49 lib/active_admin/mongoid/resource.rb
@@ -1,33 +1,32 @@
-require 'active_admin/resource'
-require 'active_admin/resource_controller'
+require 'active_admin'
+require 'inherited_resources'
-module ActiveAdmin
- class Resource
- def resource_table_name
- resource.collection_name
- end
+ActiveAdmin::Resource # autoload
+class ActiveAdmin::Resource
+ def resource_table_name
+ resource.collection_name
+ end
- # Disable filters
- def add_default_sidebar_sections
- end
+ # Disable filters
+ def add_default_sidebar_sections
end
+end
- ResourceController # autoload
- class ResourceController
- # Use #desc and #asc for sorting.
- def sort_order(chain)
- params[:order] ||= active_admin_config.sort_order
- table_name = active_admin_config.resource_table_name
- if params[:order] && params[:order] =~ /^([\w\_\.]+)_(desc|asc)$/
- chain.send($2, $1)
- else
- chain # just return the chain
- end
+ActiveAdmin::ResourceController # autoload
+class ActiveAdmin::ResourceController
+ # Use #desc and #asc for sorting.
+ def sort_order(chain)
+ params[:order] ||= active_admin_config.sort_order
+ table_name = active_admin_config.resource_table_name
+ if params[:order] && params[:order] =~ /^([\w\_\.]+)_(desc|asc)$/
+ chain.send($2, $1)
+ else
+ chain # just return the chain
end
+ end
- # Disable filters
- def search(chain)
- chain
- end
+ # Disable filters
+ def search(chain)
+ chain
end
end
View
2  lib/activeadmin-mongoid.rb
@@ -1 +1 @@
-require 'active_admin-mongoid'
+require 'active_admin/mongoid'
Please sign in to comment.
Something went wrong with that request. Please try again.