active_decorator 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -51,7 +51,7 @@ You can use the generator for doing this ( `% rails g decorator user` )
51
51
  # app/controllers/users_controller.rb
52
52
  class UsersController < ApplicationController
53
53
  def index
54
- User.all
54
+ @users = User.all
55
55
  end
56
56
  end
57
57
 
@@ -40,7 +40,8 @@ module ActiveDecorator
40
40
  d = decorator_name.constantize
41
41
  d.send :include, ActiveDecorator::Helpers
42
42
  @@decorators[model_class] = d
43
- rescue NameError
43
+ rescue NameError
44
+ @@decorators[model_class] = nil
44
45
  end
45
46
  end
46
47
  end
@@ -1,31 +1,35 @@
1
- if ActionPack::VERSION::STRING >= '3.1'
2
- class ActionView::PartialRenderer
3
- def setup_with_decorator(context, options, block) #:nodoc:
4
- setup_without_decorator context, options, block
5
-
1
+ module ActiveDecorator
2
+ module ActionViewExtension
3
+ def setup_decorator
6
4
  @locals.values.each do |v|
7
5
  ActiveDecorator::Decorator.instance.decorate v
8
- end if @locals.present?
9
- ActiveDecorator::Decorator.instance.decorate @object if @object.present?
10
- ActiveDecorator::Decorator.instance.decorate @collection if @collection.present?
6
+ end unless @locals.blank?
7
+ ActiveDecorator::Decorator.instance.decorate @object unless @object.blank?
8
+ ActiveDecorator::Decorator.instance.decorate @collection unless @collection.blank?
11
9
 
12
10
  self
13
11
  end
12
+ end
13
+ end
14
+
15
+ if ActionPack::VERSION::STRING >= '3.1'
16
+ class ActionView::PartialRenderer
17
+ include ActiveDecorator::ActionViewExtension
18
+
19
+ def setup_with_decorator(context, options, block) #:nodoc:
20
+ setup_without_decorator context, options, block
21
+ setup_decorator
22
+ end
14
23
 
15
24
  alias_method_chain :setup, :decorator
16
25
  end
17
26
  else
18
27
  class ActionView::Partials::PartialRenderer
28
+ include ActiveDecorator::ActionViewExtension
29
+
19
30
  def setup_with_decorator(options, block) #:nodoc:
20
31
  setup_without_decorator options, block
21
-
22
- @locals.values.each do |v|
23
- ActiveDecorator::Decorator.instance.decorate v
24
- end if @locals.present?
25
- ActiveDecorator::Decorator.instance.decorate @object if @object.present?
26
- ActiveDecorator::Decorator.instance.decorate @collection if @collection.present?
27
-
28
- self
32
+ setup_decorator
29
33
  end
30
34
 
31
35
  alias_method_chain :setup, :decorator
@@ -1,3 +1,3 @@
1
1
  module ActiveDecorator
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
@@ -15,8 +15,6 @@ Examples:
15
15
  DESC
16
16
 
17
17
  def create_decorator_file
18
- empty_directory 'app/decorators'
19
-
20
18
  template 'decorator.rb', File.join('app/decorators', "#{singular_name}_decorator.rb")
21
19
  end
22
20
 
@@ -3,8 +3,6 @@ module Rspec
3
3
  source_root File.expand_path('../templates', __FILE__)
4
4
 
5
5
  def create_spec_file
6
- empty_directory 'spec/decorators'
7
-
8
6
  template 'decorator_spec.rb', File.join('spec/decorators', "#{singular_name}_decorator_spec.rb")
9
7
  end
10
8
  end
@@ -3,8 +3,6 @@ module TestUnit
3
3
  source_root File.expand_path('../templates', __FILE__)
4
4
 
5
5
  def create_test_file
6
- empty_directory 'test/decorators'
7
-
8
6
  template 'decorator_test.rb', File.join('test/decorators', "#{singular_name}_decorator_test.rb")
9
7
  end
10
8
  end
metadata CHANGED
@@ -1,23 +1,33 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: active_decorator
3
- version: !ruby/object:Gem::Version
4
- version: 0.3.1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 2
10
+ version: 0.3.2
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Akira Matsuda
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-02-27 00:00:00.000000000 Z
17
+
18
+ date: 2012-04-02 00:00:00 Z
13
19
  dependencies: []
20
+
14
21
  description: A simple and Rubyish view helper for Rails 3
15
- email:
22
+ email:
16
23
  - ronnie@dio.jp
17
24
  executables: []
25
+
18
26
  extensions: []
27
+
19
28
  extra_rdoc_files: []
20
- files:
29
+
30
+ files:
21
31
  - .gitignore
22
32
  - .rspec
23
33
  - .travis.yml
@@ -54,29 +64,38 @@ files:
54
64
  - spec/spec_helper.rb
55
65
  homepage: https://github.com/amatsuda/active_decorator
56
66
  licenses: []
67
+
57
68
  post_install_message:
58
69
  rdoc_options: []
59
- require_paths:
70
+
71
+ require_paths:
60
72
  - lib
61
- required_ruby_version: !ruby/object:Gem::Requirement
73
+ required_ruby_version: !ruby/object:Gem::Requirement
62
74
  none: false
63
- requirements:
64
- - - ! '>='
65
- - !ruby/object:Gem::Version
66
- version: '0'
67
- required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ hash: 3
79
+ segments:
80
+ - 0
81
+ version: "0"
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
83
  none: false
69
- requirements:
70
- - - ! '>='
71
- - !ruby/object:Gem::Version
72
- version: '0'
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
90
+ version: "0"
73
91
  requirements: []
92
+
74
93
  rubyforge_project: active_decorator
75
- rubygems_version: 1.8.17
94
+ rubygems_version: 1.8.10
76
95
  signing_key:
77
96
  specification_version: 3
78
97
  summary: A simple and Rubyish view helper for Rails 3
79
- test_files:
98
+ test_files:
80
99
  - spec/fake_app/authors/index.html.erb
81
100
  - spec/fake_app/authors/show.html.erb
82
101
  - spec/fake_app/books/_book.html.erb