Mailinglist Archive: yast-devel (163 mails)

< Previous Next >
[yast-devel] use-activeresource: continuation
  • From: Martin Kudlvasr <mkudlvasr@xxxxxxx>
  • Date: Tue, 22 Sep 2009 14:41:43 +0200
  • Message-id: <200909221441.43437.mkudlvasr@xxxxxxx>
Hi,

I've been continuing with the work, which Martin Vidner and Karel started 2
weeks ago - trying to use ActiveResource without service_resource.rb . This is
currently the "use-activeresource" branch.

I've added support for discovering controller paths from interface name. So
currently there are no hard coded controller paths.

Previously resources were used like this:

*** Example from network_controller.rb ***
hn = load_proxy "org.opensuse.yast.modules.yapi.network.hostname"
***

Now they can be used like this:

*** plugins/network/app/model/hostname.rb ***
class Hostname < YastResource
uses_interface "org.opensuse.yast.modules.yapi.network.hostname"
end
*** Example from network_controller.rb ***
Hostname.initialize_from_interface
hn = Hostname.find :one
***

I think, that:
- this newer approach better follows the MVC philosophy (with
service_resource.rb, no model class is possible)
- the YastResource < ActiveResource class is much shorter and more readable
- individual model classes can be enriched by resource-specific methods
- YastResource and individual models are not created dynamically - and so are
easier to test (in contrast with service_resource.rb)
- test can be made for the model. Currently we depend on tests in controller.
- it is Black Magic Free (TM) :-)

Please note, that "use-activeresource" branch depends on "resource-restful"
branch, because it needs to discover individual resources (which is not
possible with current "/resources" on web-service).

This work was done to show, that there are other (and many think better)
approaches to the problem than dynamic creation of classes in
service_resource.rb. So I especially ask Duncan and Klaas, what other problems
service_resource solves and YastResource does not.

Please let me know what you think.

Martin Kudlvasr
--
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-devel+help@xxxxxxxxxxxx

< Previous Next >