active_presenters 1.1.0 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,9 +24,9 @@ module ActivePresenter
24
24
  include ActionView::Helpers::CacheHelper
25
25
  include ActionView::Helpers::DateHelper
26
26
  include ActionView::Helpers::JavaScriptHelper
27
- include ActionView::Helpers::JavaScriptMacrosHelper
27
+ # include ActionView::Helpers::JavaScriptMacrosHelper
28
28
  include ActionView::Helpers::NumberHelper
29
- include ActionView::Helpers::PaginationHelper
29
+ # include ActionView::Helpers::PaginationHelper
30
30
  include ActionView::Helpers::PrototypeHelper
31
31
  include ActionView::Helpers::ScriptaculousHelper
32
32
  attr_accessor :options
@@ -78,153 +78,80 @@ module ActivePresenter
78
78
 
79
79
  eval %{
80
80
  unless method_defined?(:#{verb}_link)
81
- def #{verb}_link(name = #{verb}_link_text, options = {}, html_options = nil, *args)
81
+ def #{verb}_link(name = #{verb}_link_text, options = {})
82
82
  options = #{verb}_link_options.merge(options)
83
- link_to(h(name), #{verb}_path, options, html_options, *args)
83
+ link_to(h(name), #{verb}_path, options)
84
84
  end
85
85
  end
86
86
  }
87
87
  end
88
88
 
89
+ # TODO: FIX THIS!!!
90
+ def protect_against_forgery?
91
+ false
92
+ end
93
+
89
94
  def destroy_link_options
90
95
  {:confirm => 'Are you sure?', :method => :delete}
91
96
  end
92
97
 
93
98
  def index_path
94
99
  ivar_cache do
95
- eval "#{self.plural}_path#{self.nested_resource_path_string}"
100
+ eval(path_builder(:type => :plural))
96
101
  end
97
102
  end
98
103
 
99
104
  def show_path
100
105
  ivar_cache do
101
- eval "#{self.singular}_path#{self.nested_resource_path_string(true)}"
106
+ eval(path_builder(:include_self => true))
102
107
  end
103
108
  end
104
109
 
105
110
  def new_path
106
111
  ivar_cache do
107
- eval "new_#{self.singular}_path#{self.nested_resource_path_string}"
112
+ eval(path_builder(:prefix => "new"))
108
113
  end
109
114
  end
110
115
 
111
116
  def create_path
112
117
  ivar_cache do
113
- eval "#{self.plural}_path#{self.nested_resource_path_string}"
118
+ eval(path_builder(:type => :plural))
114
119
  end
115
120
  end
116
121
 
117
122
  def edit_path
118
123
  ivar_cache do
119
- eval "edit_#{self.singular}_path#{self.nested_resource_path_string(true)}"
124
+ eval(path_builder(:prefix => "edit", :include_self => true))
120
125
  end
121
126
  end
122
127
 
123
128
  def update_path
124
129
  ivar_cache do
125
- eval "#{self.singular}_path#{self.nested_resource_path_string(true)}"
130
+ eval(path_builder(:include_self => true))
126
131
  end
127
132
  end
128
133
 
129
134
  def destroy_path
130
135
  ivar_cache do
131
- eval "#{self.singular}_path#{self.nested_resource_path_string(true)}"
136
+ eval(path_builder(:include_self => true))
132
137
  end
133
138
  end
134
139
 
135
140
 
136
141
  protected
137
142
 
138
- # def build_common_ar_resource_methods
139
- # instance_eval do
140
- # unless method_defined?(:destroy_link_options)
141
- # def destroy_link_options
142
- # {:confirm => 'Are you sure?', :method => :delete}
143
- # end
144
- # end
145
- # end
146
- #
147
- # instance_eval do
148
- # REST_VERBS.each_pair do |verb, meth|
149
- # eval %{
150
- # unless method_defined?(:#{verb}_link_text)
151
- # def #{verb}_link_text
152
- # "#{verb}"
153
- # end
154
- # end
155
- #
156
- # unless method_defined?(:#{verb}_link_options)
157
- # def #{verb}_link_options
158
- # #{meth == :get ? "{}" : "{:method => :#{meth}}"}
159
- # end
160
- # end
161
- #
162
- # unless method_defined?(:#{verb}_link)
163
- # def #{verb}_link(name = #{verb}_link_text, options = {}, html_options = nil, *args)
164
- # options = #{verb}_link_options.merge(options)
165
- # link_to(h(name), #{verb}_path, options, html_options, *args)
166
- # end
167
- # end
168
- # }
169
- # end
170
- # end
171
- # end
172
- #
173
- # def build_ar_resource_methods
174
- # instance_eval do
175
- # eval %{
176
- # unless method_defined?(:index_path)
177
- # def index_path
178
- # #{self.plural}_path#{self.nested_resource_path_string}
179
- # end
180
- # end
181
- #
182
- # unless method_defined?(:show_path)
183
- # def show_path
184
- # #{self.singular}_path#{self.nested_resource_path_string(true)}
185
- # end
186
- # end
187
- #
188
- # unless method_defined?(:new_path)
189
- # def new_path
190
- # new_#{self.singular}_path#{self.nested_resource_path_string}
191
- # end
192
- # end
193
- #
194
- # unless method_defined?(:create_path)
195
- # def create_path
196
- # #{self.plural}_path#{self.nested_resource_path_string}
197
- # end
198
- # end
199
- #
200
- # unless method_defined?(:edit_path)
201
- # def edit_path
202
- # edit_#{self.singular}_path#{self.nested_resource_path_string(true)}
203
- # end
204
- # end
205
- #
206
- # unless method_defined?(:update_path)
207
- # def update_path
208
- # #{self.singular}_path#{self.nested_resource_path_string(true)}
209
- # end
210
- # end
211
- #
212
- # unless method_defined?(:destroy_path)
213
- # def destroy_path
214
- # #{self.singular}_path#{self.nested_resource_path_string(true)}
215
- # end
216
- # end
217
- # }
218
- #
219
- # end
220
- #
221
- # end
222
-
223
- def nested_resource_path_string(include_self = false)
224
- x = self.model.nested_resource.nil? ? '' : "self.model.nested_resource"
225
- x << (x.blank? ? '' : ", ") << "self.model" if include_self
143
+ def path_builder(options = {})
144
+ options = {:prefix => "", :type => :singular, :include_self => false}.merge(options)
145
+ path = ""
146
+ path << options[:prefix] << "_" unless options[:prefix].blank?
147
+ path << (self.model.nested_resource.nil? ? '' : "#{self.model.nested_resource.class.name.underscore}_")
148
+ path << self.send(options[:type]) << "_path"
149
+ x = (self.model.nested_resource.nil? ? '' : "self.model.nested_resource")
150
+ x << (x.blank? ? '' : ", ") << "self.model" if options[:include_self]
226
151
  x = "(#{x})" unless x.blank?
227
- x
152
+ path << x
153
+ # puts path
154
+ path
228
155
  end
229
156
 
230
157
  def plural
@@ -2,4 +2,4 @@
2
2
  gem_name: active_presenters
3
3
  package: active_presenters
4
4
  project: magrathea
5
- version: 1.1.0
5
+ version: 1.1.4
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: active_presenters
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.1.0
7
- date: 2007-10-04 00:00:00 -04:00
6
+ version: 1.1.4
7
+ date: 2007-11-12 00:00:00 -05:00
8
8
  summary: active_presenters
9
9
  require_paths:
10
10
  - lib