2012-05-09 18:02:54 -04:00
|
|
|
require 'action_view'
|
2013-01-31 04:41:52 -05:00
|
|
|
require 'active_model/naming'
|
2013-01-16 22:17:11 -05:00
|
|
|
require 'active_model/serialization'
|
2013-01-31 04:41:52 -05:00
|
|
|
require 'active_model/serializers/json'
|
|
|
|
require 'active_model/serializers/xml'
|
2013-01-16 22:17:11 -05:00
|
|
|
require 'active_support/inflector'
|
|
|
|
require 'active_support/core_ext/hash/keys'
|
|
|
|
require 'active_support/core_ext/hash/reverse_merge'
|
2013-05-20 06:16:01 -04:00
|
|
|
require 'active_support/core_ext/name_error'
|
2012-05-09 18:02:54 -04:00
|
|
|
|
|
|
|
require 'draper/version'
|
2017-03-31 10:05:15 -04:00
|
|
|
require 'draper/configuration'
|
2012-10-16 10:38:51 -04:00
|
|
|
require 'draper/view_helpers'
|
2013-01-13 22:27:58 -05:00
|
|
|
require 'draper/delegation'
|
|
|
|
require 'draper/automatic_delegation'
|
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'
|
2013-02-06 18:45:35 -05:00
|
|
|
require 'draper/factory'
|
2012-11-08 08:06:24 -05:00
|
|
|
require 'draper/decorated_association'
|
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'
|
2014-04-22 17:05:55 -04:00
|
|
|
require 'draper/undecorate'
|
2013-02-06 19:39:42 -05:00
|
|
|
require 'draper/decorates_assigned'
|
2012-03-14 14:17:07 -04:00
|
|
|
require 'draper/railtie' if defined?(Rails)
|
2012-05-09 13:32:58 -04:00
|
|
|
|
2012-10-31 20:16:09 -04:00
|
|
|
module Draper
|
2017-03-31 10:05:15 -04:00
|
|
|
extend Draper::Configuration
|
|
|
|
|
2012-11-13 15:44:39 -05:00
|
|
|
def self.setup_action_controller(base)
|
|
|
|
base.class_eval do
|
|
|
|
include Draper::ViewContext
|
|
|
|
extend Draper::HelperSupport
|
2013-02-06 19:39:42 -05:00
|
|
|
extend Draper::DecoratesAssigned
|
2013-01-18 11:40:57 -05:00
|
|
|
|
2016-07-04 17:08:25 -04:00
|
|
|
before_action :activate_draper
|
2012-11-13 15:44:39 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.setup_action_mailer(base)
|
|
|
|
base.class_eval do
|
|
|
|
include Draper::ViewContext
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-12-11 15:59:49 -05:00
|
|
|
def self.setup_orm(base)
|
2012-11-13 15:44:39 -05:00
|
|
|
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
|
2012-12-02 07:20:42 -05:00
|
|
|
|
2017-03-28 13:56:50 -04:00
|
|
|
class UninferrableObjectError < NameError
|
2012-12-02 07:20:42 -05:00
|
|
|
def initialize(klass)
|
2017-03-28 13:56:50 -04:00
|
|
|
super("Could not infer an object for #{klass}.")
|
2012-12-02 07:20:42 -05:00
|
|
|
end
|
|
|
|
end
|
2012-10-31 20:16:09 -04:00
|
|
|
end
|