view_models 2.0.0.ruby19 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,32 @@
|
|
1
|
+
h1. module ModulesInRenderHierarchy
|
2
|
+
|
3
|
+
Why would we need that?
|
4
|
+
|
5
|
+
h2. Situation
|
6
|
+
|
7
|
+
We have a music platform. There we have public profiles, and private profiles. And of each type a band, and a venue profile.
|
8
|
+
|
9
|
+
Public / Private have different functionality, and also Band / Venue.
|
10
|
+
|
11
|
+
The chose class structure looks like this:
|
12
|
+
|
13
|
+
@Public::Base < Project@, @Private::Base < Project@
|
14
|
+
@Public::Band < Public::Base@, @Public::Venue < Public::Base@, @Private::Band < Private::Base@, @Private::Venue < Private::Base@
|
15
|
+
|
16
|
+
To not have duplicate code, we include the functionality for Bands and Venues by using @include BandFunctionality@ and @include VenueFunctionality@.
|
17
|
+
|
18
|
+
h2. Problem
|
19
|
+
|
20
|
+
When rendering using the hierarchical rendering, we look up the templates as follows:
|
21
|
+
|
22
|
+
(For ViewModels::Public::Band#render_as :example, :format => :html)
|
23
|
+
# @views/view_models/public/band/_example.html.erb@
|
24
|
+
# @views/view_models/public/base/_example.html.erb@
|
25
|
+
# @views/view_models/project/_example.html.erb@
|
26
|
+
|
27
|
+
So the example template is taken from the @public/band@ directory. Why not from a @functionality/band@ directory (assuming the module is named @Functionality::Band@). The reason for this is that the current (v1.5.4) hierarchical rendering process uses superclass, which hops over Modules, rather than using ancestors, which wouldn't.
|
28
|
+
|
29
|
+
h2. Solution
|
30
|
+
|
31
|
+
#. Either override superclass, with all associated problems
|
32
|
+
#. Or refit the whole hierarchical rendering into a HierarchicalRendering Class. (Preferred)
|
@@ -88,7 +88,7 @@ module ViewModels
|
|
88
88
|
# Combines left parentheses and filters.
|
89
89
|
#
|
90
90
|
def filtered_left_parentheses
|
91
|
-
filters.zip(left_parentheses).
|
91
|
+
filters.zip(left_parentheses).to_s
|
92
92
|
end
|
93
93
|
|
94
94
|
# Generates the needed amount of parentheses to match the left parentheses.
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: view_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 15
|
5
|
+
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 2
|
7
8
|
- 0
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 2.0.0.ruby19
|
10
|
+
version: 2.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Florian Hanke
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2010-07-
|
21
|
+
date: 2010-07-20 00:00:00 +02:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
@@ -29,6 +29,7 @@ dependencies:
|
|
29
29
|
requirements:
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
+
hash: 7
|
32
33
|
segments:
|
33
34
|
- 2
|
34
35
|
- 2
|
@@ -44,6 +45,7 @@ dependencies:
|
|
44
45
|
requirements:
|
45
46
|
- - ">="
|
46
47
|
- !ruby/object:Gem::Version
|
48
|
+
hash: 13
|
47
49
|
segments:
|
48
50
|
- 1
|
49
51
|
- 2
|
@@ -68,6 +70,7 @@ files:
|
|
68
70
|
- lib/padrino/lib/view_models/base.rb
|
69
71
|
- lib/rails2/README.textile
|
70
72
|
- lib/rails2/TODO.textile
|
73
|
+
- lib/rails2/generators/view_models/USAGE
|
71
74
|
- lib/rails2/generators/view_models/templates/README
|
72
75
|
- lib/rails2/generators/view_models/templates/spec/view_model_spec.rb
|
73
76
|
- lib/rails2/generators/view_models/templates/view_models/view_model.rb
|
@@ -81,18 +84,19 @@ files:
|
|
81
84
|
- lib/rails2/generators/view_models/templates/views/view_models/collection/_pagination.text.erb
|
82
85
|
- lib/rails2/generators/view_models/templates/views/view_models/collection/_table.html.haml
|
83
86
|
- lib/rails2/generators/view_models/templates/views/view_models/collection/_table.text.erb
|
84
|
-
- lib/rails2/generators/view_models/USAGE
|
85
87
|
- lib/rails2/generators/view_models/view_models_generator.rb
|
86
88
|
- lib/rails2/init.rb
|
89
|
+
- lib/rails2/lib/experimental/README.textile
|
87
90
|
- lib/rails2/lib/experimental/modules_in_render_hierarchy.rb
|
88
91
|
- lib/rails2/lib/extensions/view.rb
|
89
92
|
- lib/rails2/lib/helpers/collection.rb
|
90
93
|
- lib/rails2/lib/helpers/view.rb
|
94
|
+
- lib/rails2/lib/view_models.rb
|
91
95
|
- lib/rails2/lib/view_models/base.rb
|
92
96
|
- lib/rails2/lib/view_models/view.rb
|
93
|
-
- lib/rails2/lib/view_models.rb
|
94
97
|
- lib/shared/README.textile
|
95
98
|
- lib/shared/init.rb
|
99
|
+
- lib/shared/lib/view_models.rb
|
96
100
|
- lib/shared/lib/view_models/base.rb
|
97
101
|
- lib/shared/lib/view_models/context_extractor.rb
|
98
102
|
- lib/shared/lib/view_models/extensions/active_record.rb
|
@@ -101,7 +105,6 @@ files:
|
|
101
105
|
- lib/shared/lib/view_models/helpers/mapping.rb
|
102
106
|
- lib/shared/lib/view_models/path_store.rb
|
103
107
|
- lib/shared/lib/view_models/render_options.rb
|
104
|
-
- lib/shared/lib/view_models.rb
|
105
108
|
- lib/view_models.rb
|
106
109
|
has_rdoc: true
|
107
110
|
homepage: http://floere.github.com/view_models
|
@@ -118,6 +121,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
121
|
requirements:
|
119
122
|
- - ">="
|
120
123
|
- !ruby/object:Gem::Version
|
124
|
+
hash: 3
|
121
125
|
segments:
|
122
126
|
- 0
|
123
127
|
version: "0"
|
@@ -126,6 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
130
|
requirements:
|
127
131
|
- - ">="
|
128
132
|
- !ruby/object:Gem::Version
|
133
|
+
hash: 3
|
129
134
|
segments:
|
130
135
|
- 0
|
131
136
|
version: "0"
|