Proposed API change for respond_to

Chris Farmiloe chris at oxdi.eu
Sat Sep 22 08:34:22 EDT 2007




On 21 Sep 2007, at 21:22, Duane Johnson wrote:
>  With this architecture, we could take
> advantage of inheritance in the OO way (as well as map exceptions to
> actions the OO way):

I think this is an interesting point!



With more of my projects taking the REST view on the world, I'll  
often have a base controller with common create/update/show/delete  
methods, that I then overide if they need modifying.

By taking an approach where actions are classes, this situation might  
be improved.

Worth thinking about ... but is quite a step away from the current  
"way" that it's not going to be an easy switch.

might the idea maybe be to have:

app/controllers/users/index.rb

class Users::Index < Users::Action
	def to_html
		render
	end

	def to_xml
		'<xml/>'
	end
end

which then renders the template at

app/views/users/index.html.erb


where Users::Action is the base "action" class for users (where you  
would put all your methods that all user actions require) and  
Users::Action is inherited from Application::Action (where all the  
app-level methods are) which is a Merb::Action

I think the GetAction idea is poor and all that sort of logic should  
stay in the router code.

I like the ideas of the matching up of the action.rb file and the  
template.erb, but I'm not entirly convinced, the directory structures  
in /controller and /views would be nicely mirrored.


anyway this is all very theoretical, more things for the _ry- 
experimental-playground-branch ;)





Regards

Farms.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/merb-devel/attachments/20070922/0c81d94d/attachment.html 


More information about the Merb-devel mailing list