Skip to content

Commit

Permalink
Blush is now tied in with railties
Browse files Browse the repository at this point in the history
  • Loading branch information
blaknite committed May 18, 2016
1 parent f95c004 commit b0cbdec
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
5 changes: 1 addition & 4 deletions lib/blush.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'blush/helper_proxy'
require 'blush/presenter'
require 'blush/view_context'
require 'blush/railtie'

##
# Wrapper module for Blush
Expand Down Expand Up @@ -31,7 +32,3 @@ module Blush
end

end

ActiveRecord::Base.send :extend, Blush::HasPresenter
ActionController::Base.send :include, Blush::ViewContext
ActionMailer::Base.send :include, Blush::ViewContext
29 changes: 29 additions & 0 deletions lib/blush/railtie.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module Blush
class Railtie < Rails::Railtie
initializer "blush.setup_action_controller" do |app|
ActiveSupport.on_load :action_controller do
self.class_eval do
include Blush::ViewContext
end
end
end

initializer "blush.setup_action_mailer" do |app|
ActiveSupport.on_load :action_mailer do
self.class_eval do
include Blush::ViewContext

before_filter :set_blush_helpers
end
end
end

initializer "blush.setup_orm" do |app|
ActiveSupport.on_load :active_record do
self.class_eval do
extend Blush::HasPresenter
end
end
end
end
end

0 comments on commit b0cbdec

Please sign in to comment.