Remove System namespace

This commit is contained in:
Andrew Haines 2012-11-13 20:44:39 +00:00
parent cfbc3888e9
commit 4f9b23c077
4 changed files with 27 additions and 25 deletions

View File

@ -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/rspec_integration' if defined?(RSpec) and RSpec.respond_
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 File

@ -24,19 +24,19 @@ module Draper
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 File

@ -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 File

@ -1,6 +1,6 @@
module ActionController
class Base
Draper::System.setup_action_controller(self)
Draper.setup_action_controller(self)
end
end