-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All helper methods now proxied through the current view_context
- Loading branch information
Showing
4 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
require 'blush/configuration' | ||
require 'blush/has_presenter' | ||
require 'blush/helper_proxy' | ||
require 'blush/presenter' | ||
require 'blush/view_context' | ||
|
||
module Blush | ||
module_function def config | ||
@config ||= Blush::Configuration.new | ||
end | ||
|
||
module_function def helpers=(view_context) | ||
@helpers = view_context | ||
end | ||
|
||
module_function def helpers | ||
@helpers ||= ActionView::Base.new | ||
@helpers ||= ApplicationController.helpers | ||
end | ||
end | ||
|
||
ActiveRecord::Base.send :extend, Blush::HasPresenter | ||
ActionController::Base.send :include, Blush::ViewContext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Blush | ||
class HelperProxy | ||
def method_missing(method, *args, &block) | ||
Blush.helpers.send(method, *args, &block) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Blush | ||
module ViewContext | ||
def view_context | ||
super.tap do |context| | ||
Blush.helpers = context | ||
end | ||
end | ||
end | ||
end |