-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
32 additions
and
9 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,4 +1,3 @@ | ||
require 'active_decorator/version' | ||
require 'active_decorator/decorator' | ||
require 'active_decorator/railtie' | ||
|
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,21 +1,14 @@ | ||
require 'action_view' | ||
|
||
module ActiveDecorator | ||
module Helpers | ||
def method_missing(method, *args, &block) | ||
super | ||
#TODO need to make sure who raised the error? | ||
rescue NoMethodError => no_method_error | ||
begin | ||
@@_decorator_view_proxy ||= DecoratorViewProxy.new | ||
@@_decorator_view_proxy.send method, *args, &block | ||
ActiveDecorator::ViewContext.current.send method, *args, &block | ||
rescue NoMethodError | ||
raise no_method_error | ||
end | ||
end | ||
|
||
class DecoratorViewProxy | ||
include ::ActionView::Helpers | ||
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,23 @@ | ||
module ActiveDecorator | ||
module ViewContext | ||
class << self | ||
def current | ||
Thread.current[:view_context] | ||
end | ||
|
||
def current=(view_context) | ||
Thread.current[:view_context] = view_context | ||
end | ||
end | ||
|
||
module Filter | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
before_filter do |controller| | ||
ActiveDecorator::ViewContext.current = controller.view_context | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
<%= @book.link %> | ||
<%= @book.cover_image %> |
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 |
---|---|---|
|
@@ -11,5 +11,6 @@ | |
within 'a' do | ||
page.should have_content 'RHG' | ||
end | ||
page.should have_css('img') | ||
end | ||
end |