Search the web
Sign In
New User? Sign Up
rails_artist · Only Ruby on Rails Artist here
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
moderate use of dynamic feature   Message List  
Reply | Forward Message #21 of 23 |
hi,
i was wondering why the following line of codes were written -
i found it from action_controller/test_process.rb file.

def self.included(base)
# execute the request simulating a specific http method and set/
volley the response
%w( get post put delete head ).each do |method|
base.class_eval <<-EOV, __FILE__, __LINE__
def #{method}(action, parameters = nil, session = nil, flash
= nil)
@request.env['REQUEST_METHOD'] = "#{method.upcase}" if
defined?(@request)
process(action, parameters, session, flash)
end
EOV
end
end

i believe, this was trying to make this code more DRY'ed, but this
think might be confusion for other sufferer.
because this "get, post, put, delete, head" methods are not reflected
during RDoc compilation.

unless we get some solution like "monitor loaded class behavior and
render documentation based upon their meta information" for example
-
%w( get post put delete head ).each do |method|
base.class_eval <<-EOV, __FILE__, __LINE__
desc "delegating process method"
def #{method}(action, parameters = nil, session = nil,
flash = nil)
@request.env['REQUEST_METHOD'] = "#{method.upcase}" if
defined?(@request)
process(action, parameters, session, flash)
end
EOV
end

i would really love to see this kind of code is broken into the
following code -
# delegating process method
def post(action, parameters = nil, session = nil, flash = nil)
@request.env['REQUEST_METHOD'] = "#{method.upcase}" if defined?
(@request)
process(action, parameters, session, flash)
end

# delegating process method
def get(action, parameters = nil, session = nil, flash = nil)
@request.env['REQUEST_METHOD'] = "#{method.upcase}" if defined?
(@request)
process(action, parameters, session, flash)
end
....

best wishes,




Sat Apr 19, 2008 4:22 pm

hasan83bd
Offline Offline
Send Email Send Email

Forward
Message #21 of 23 |
Expand Messages Author Sort by Date

hi, i was wondering why the following line of codes were written - i found it from action_controller/test_process.rb file. def self.included(base) # execute...
hasan83bd
Offline Send Email
Apr 19, 2008
4:22 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help