Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove System namespace

  • Loading branch information...
commit 4f9b23c077121267e6802dfaa598d05999f3010a 1 parent cfbc388
@haines haines authored
View
24 lib/draper.rb
@@ -1,7 +1,6 @@
require 'action_view'
require 'draper/version'
-require 'draper/system'
require 'draper/view_helpers'
require 'draper/finders'
require 'draper/decorator'
@@ -20,6 +19,29 @@
require 'draper/test/minitest_integration' if defined?(MiniTest::Rails)
module Draper
+ def self.setup_action_controller(base)
+ base.class_eval do
+ include Draper::ViewContext
+ extend Draper::HelperSupport
+ before_filter ->(controller) {
+ Draper::ViewContext.current = nil
+ Draper::ViewContext.current_controller = controller
+ }
+ end
+ end
+
+ def self.setup_action_mailer(base)
+ base.class_eval do
+ include Draper::ViewContext
+ end
+ end
+
+ def self.setup_active_record(base)
+ base.class_eval do
+ include Draper::Decoratable
+ end
+ end
+
class UninferrableDecoratorError < NameError
def initialize(klass)
super("Could not infer a decorator for #{klass}.")
View
6 lib/draper/railtie.rb
@@ -24,19 +24,19 @@ class Railtie < Rails::Railtie
initializer "draper.extend_action_controller_base" do |app|
ActiveSupport.on_load(:action_controller) do
- Draper::System.setup_action_controller(self)
+ Draper.setup_action_controller(self)
end
end
initializer "draper.extend_action_mailer_base" do |app|
ActiveSupport.on_load(:action_mailer) do
- Draper::System.setup_action_mailer(self)
+ Draper.setup_action_mailer(self)
end
end
initializer "draper.extend_active_record_base" do |app|
ActiveSupport.on_load(:active_record) do
- self.send(:include, Draper::Decoratable)
+ Draper.setup_active_record(self)
end
end
View
20 lib/draper/system.rb
@@ -1,20 +0,0 @@
-module Draper
- class System
- def self.setup_action_controller(component)
- component.class_eval do
- include Draper::ViewContext
- extend Draper::HelperSupport
- before_filter lambda {|controller|
- Draper::ViewContext.current = nil
- Draper::ViewContext.current_controller = controller
- }
- end
- end
-
- def self.setup_action_mailer(component)
- component.class_eval do
- include Draper::ViewContext
- end
- end
- end
-end
View
2  spec/support/action_controller.rb
@@ -1,6 +1,6 @@
module ActionController
class Base
- Draper::System.setup_action_controller(self)
+ Draper.setup_action_controller(self)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.