2012-05-09 18:02:54 -04:00
|
|
|
require 'action_view'
|
|
|
|
|
|
|
|
require 'draper/version'
|
2012-10-16 10:38:51 -04:00
|
|
|
require 'draper/view_helpers'
|
2012-10-14 18:35:25 -04:00
|
|
|
require 'draper/finders'
|
2012-10-09 04:51:40 -04:00
|
|
|
require 'draper/decorator'
|
2012-10-14 18:01:15 -04:00
|
|
|
require 'draper/helper_proxy'
|
2011-07-13 01:00:10 -04:00
|
|
|
require 'draper/lazy_helpers'
|
2012-10-09 05:11:57 -04:00
|
|
|
require 'draper/decoratable'
|
2012-11-08 08:06:24 -05:00
|
|
|
require 'draper/decorated_association'
|
2012-10-12 05:37:39 -04:00
|
|
|
require 'draper/security'
|
2011-10-28 22:20:28 -04:00
|
|
|
require 'draper/helper_support'
|
2011-10-08 01:06:19 -04:00
|
|
|
require 'draper/view_context'
|
2012-10-09 05:07:14 -04:00
|
|
|
require 'draper/collection_decorator'
|
2012-03-14 14:17:07 -04:00
|
|
|
require 'draper/railtie' if defined?(Rails)
|
2012-05-09 13:32:58 -04:00
|
|
|
|
2012-05-18 01:54:13 -04:00
|
|
|
# Test Support
|
2012-11-29 20:01:25 -05:00
|
|
|
require 'draper/test/rspec_integration' if defined?(RSpec) and RSpec.respond_to?(:configure)
|
|
|
|
require 'draper/test/minitest_integration' if defined?(MiniTest::Rails)
|
|
|
|
require 'draper/test/test_unit_integration'
|
2012-10-31 20:16:09 -04:00
|
|
|
|
|
|
|
module Draper
|
2012-11-13 15:44:39 -05:00
|
|
|
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
|
|
|
|
|
2012-10-31 20:16:09 -04:00
|
|
|
class UninferrableDecoratorError < NameError
|
|
|
|
def initialize(klass)
|
|
|
|
super("Could not infer a decorator for #{klass}.")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|