Sha256: c7ebcc540e8d0e2ce0cc1f7026b3d24b70d2f09d5916ad08d82906cd8bd5b01f
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
require 'request_store' require "easy_presenter/version" require "easy_presenter/base" require "easy_presenter/railtie" module EasyPresenter extend ActiveSupport::Concern included do include_easy_presenter end module ClassMethods def inherited(subclass) include_easy_presenter(subclass) super end protected def include_easy_presenter(klass=self) presenter_class = "#{klass}Presenter".safe_constantize if presenter_class presenter_class.extend ActiveSupport::Concern klass.send :include, presenter_class klass.send :include, Base end presenter_class end end # for the Presenter module only class << self def controller RequestStore.store[:presenter_controller] end def controller=(presenter_controller) RequestStore.store[:presenter_controller] = presenter_controller end end end if defined?(ActiveRecord::Base) ActiveRecord::Base.send :include, EasyPresenter elsif defined?(Mongoid::Document) Mongoid::Document.send :include, EasyPresenter end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
easy_presenter-1.1.1 | lib/easy_presenter.rb |