proxy_for_template 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/proxy_for_template/version.rb +1 -1
- data/lib/proxy_for_template.rb +18 -16
- metadata +4 -4
data/lib/proxy_for_template.rb
CHANGED
@@ -97,7 +97,7 @@ module ProxyForTemplate
|
|
97
97
|
|
98
98
|
def proxy_attribute_read(method)
|
99
99
|
|
100
|
-
|
100
|
+
|
101
101
|
self_value = nil
|
102
102
|
|
103
103
|
if(template_responds_to?(method))
|
@@ -115,17 +115,9 @@ module ProxyForTemplate
|
|
115
115
|
|
116
116
|
def proxy_read(method)
|
117
117
|
|
118
|
-
template_value =
|
118
|
+
template_value = value_from_template(method)
|
119
119
|
self_value = nil
|
120
120
|
|
121
|
-
if(template_responds_to?(method))
|
122
|
-
template_value = template.send(method)
|
123
|
-
end
|
124
|
-
|
125
|
-
if(!template_value.nil? && treat_as_nil?(method, template_value))
|
126
|
-
template_value = nil
|
127
|
-
end
|
128
|
-
|
129
121
|
self_value = self.send(method + '_orig')
|
130
122
|
|
131
123
|
if template_takes_precedence(method) && !(template_value.nil? || template_value == '')
|
@@ -135,18 +127,28 @@ module ProxyForTemplate
|
|
135
127
|
self_value
|
136
128
|
end
|
137
129
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
if(
|
142
|
-
|
130
|
+
def value_from_template(method)
|
131
|
+
template_value = nil
|
132
|
+
|
133
|
+
if(template_responds_to?(method))
|
134
|
+
template_value = template.send(method)
|
143
135
|
end
|
144
136
|
|
137
|
+
if(!template_value.nil? && treat_as_nil?(method, template_value))
|
138
|
+
template_value = nil
|
139
|
+
end
|
140
|
+
|
141
|
+
template_value
|
142
|
+
end
|
143
|
+
|
144
|
+
def templated?(method)
|
145
|
+
value = value_from_template(method)
|
146
|
+
|
145
147
|
blank = (value.nil? || value == '')
|
146
148
|
!blank
|
147
149
|
end
|
148
150
|
|
149
151
|
def template_responds_to?(method)
|
150
|
-
(respond_to?(:template) && template && template.respond_to?(method))
|
152
|
+
(respond_to?(:template) && templated_methods.include?(method.to_sym) && template && template.respond_to?(method))
|
151
153
|
end
|
152
154
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proxy_for_template
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mike Emery
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-01-
|
18
|
+
date: 2012-01-18 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|