Skip to content

Commit

Permalink
Remove System namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
haines committed Nov 13, 2012
1 parent cfbc388 commit 4f9b23c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 25 deletions.
24 changes: 23 additions & 1 deletion lib/draper.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'action_view' require 'action_view'


require 'draper/version' require 'draper/version'
require 'draper/system'
require 'draper/view_helpers' require 'draper/view_helpers'
require 'draper/finders' require 'draper/finders'
require 'draper/decorator' require 'draper/decorator'
Expand All @@ -20,6 +19,29 @@
require 'draper/test/minitest_integration' if defined?(MiniTest::Rails) require 'draper/test/minitest_integration' if defined?(MiniTest::Rails)


module Draper 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 class UninferrableDecoratorError < NameError
def initialize(klass) def initialize(klass)
super("Could not infer a decorator for #{klass}.") super("Could not infer a decorator for #{klass}.")
Expand Down
6 changes: 3 additions & 3 deletions lib/draper/railtie.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ class Railtie < Rails::Railtie


initializer "draper.extend_action_controller_base" do |app| initializer "draper.extend_action_controller_base" do |app|
ActiveSupport.on_load(:action_controller) do ActiveSupport.on_load(:action_controller) do
Draper::System.setup_action_controller(self) Draper.setup_action_controller(self)
end end
end end


initializer "draper.extend_action_mailer_base" do |app| initializer "draper.extend_action_mailer_base" do |app|
ActiveSupport.on_load(:action_mailer) do ActiveSupport.on_load(:action_mailer) do
Draper::System.setup_action_mailer(self) Draper.setup_action_mailer(self)
end end
end end


initializer "draper.extend_active_record_base" do |app| initializer "draper.extend_active_record_base" do |app|
ActiveSupport.on_load(:active_record) do ActiveSupport.on_load(:active_record) do
self.send(:include, Draper::Decoratable) Draper.setup_active_record(self)
end end
end end


Expand Down
20 changes: 0 additions & 20 deletions lib/draper/system.rb

This file was deleted.

2 changes: 1 addition & 1 deletion spec/support/action_controller.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
module ActionController module ActionController
class Base class Base
Draper::System.setup_action_controller(self) Draper.setup_action_controller(self)
end end
end end


Expand Down

0 comments on commit 4f9b23c

Please sign in to comment.