active_decorator 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/active_decorator.rb +0 -1
- data/lib/active_decorator/helpers.rb +1 -8
- data/lib/active_decorator/railtie.rb +2 -0
- data/lib/active_decorator/version.rb +1 -1
- data/lib/active_decorator/view_context.rb +23 -0
- data/spec/fake_app/books/show.html.erb +1 -0
- data/spec/fake_app/fake_app.rb +4 -0
- data/spec/requests/action_view_helpers_spec.rb +1 -0
- metadata +12 -17
data/lib/active_decorator.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'action_view'
|
2
|
-
|
3
1
|
module ActiveDecorator
|
4
2
|
module Helpers
|
5
3
|
def method_missing(method, *args, &block)
|
@@ -7,15 +5,10 @@ module ActiveDecorator
|
|
7
5
|
#TODO need to make sure who raised the error?
|
8
6
|
rescue NoMethodError => no_method_error
|
9
7
|
begin
|
10
|
-
|
11
|
-
@@_decorator_view_proxy.send method, *args, &block
|
8
|
+
ActiveDecorator::ViewContext.current.send method, *args, &block
|
12
9
|
rescue NoMethodError
|
13
10
|
raise no_method_error
|
14
11
|
end
|
15
12
|
end
|
16
|
-
|
17
|
-
class DecoratorViewProxy
|
18
|
-
include ::ActionView::Helpers
|
19
|
-
end
|
20
13
|
end
|
21
14
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'active_decorator/view_context'
|
1
2
|
require 'rails'
|
2
3
|
|
3
4
|
module ActiveDecorator
|
@@ -8,6 +9,7 @@ module ActiveDecorator
|
|
8
9
|
end
|
9
10
|
ActiveSupport.on_load(:action_controller) do
|
10
11
|
require 'active_decorator/monkey/abstract_controller/rendering'
|
12
|
+
ActionController::Base.send :include, ActiveDecorator::ViewContext::Filter
|
11
13
|
end
|
12
14
|
ActiveSupport.on_load(:action_mailer) do
|
13
15
|
require 'active_decorator/monkey/abstract_controller/rendering'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ActiveDecorator
|
2
|
+
module ViewContext
|
3
|
+
class << self
|
4
|
+
def current
|
5
|
+
Thread.current[:view_context]
|
6
|
+
end
|
7
|
+
|
8
|
+
def current=(view_context)
|
9
|
+
Thread.current[:view_context] = view_context
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module Filter
|
14
|
+
extend ActiveSupport::Concern
|
15
|
+
|
16
|
+
included do
|
17
|
+
before_filter do |controller|
|
18
|
+
ActiveDecorator::ViewContext.current = controller.view_context
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/fake_app/fake_app.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_decorator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-02-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &70226630611740 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70226630611740
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec-rails
|
27
|
-
requirement: &
|
27
|
+
requirement: &70226630609000 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70226630609000
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: capybara
|
38
|
-
requirement: &
|
38
|
+
requirement: &70226630606920 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70226630606920
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: sqlite3
|
49
|
-
requirement: &
|
49
|
+
requirement: &70226630605800 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70226630605800
|
58
58
|
description: A simple and Rubyish view helper for Rails 3
|
59
59
|
email:
|
60
60
|
- ronnie@dio.jp
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- lib/active_decorator/monkey/action_view/partial_renderer.rb
|
78
78
|
- lib/active_decorator/railtie.rb
|
79
79
|
- lib/active_decorator/version.rb
|
80
|
+
- lib/active_decorator/view_context.rb
|
80
81
|
- lib/generators/rails/decorator_generator.rb
|
81
82
|
- lib/generators/rails/templates/decorator.rb
|
82
83
|
- lib/generators/rspec/decorator_generator.rb
|
@@ -105,21 +106,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
106
|
- - ! '>='
|
106
107
|
- !ruby/object:Gem::Version
|
107
108
|
version: '0'
|
108
|
-
segments:
|
109
|
-
- 0
|
110
|
-
hash: -1770381626412442444
|
111
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
110
|
none: false
|
113
111
|
requirements:
|
114
112
|
- - ! '>='
|
115
113
|
- !ruby/object:Gem::Version
|
116
114
|
version: '0'
|
117
|
-
segments:
|
118
|
-
- 0
|
119
|
-
hash: -1770381626412442444
|
120
115
|
requirements: []
|
121
116
|
rubyforge_project: active_decorator
|
122
|
-
rubygems_version: 1.8.
|
117
|
+
rubygems_version: 1.8.17
|
123
118
|
signing_key:
|
124
119
|
specification_version: 3
|
125
120
|
summary: A simple and Rubyish view helper for Rails 3
|