Mailinglist Archive: yast-devel (144 mails)

< Previous Next >
Re: [yast-devel] Help: Lost in Ruby
On Wed, 7 Aug 2013 12:01:18 +0200
Arvin Schnell <aschnell@xxxxxxx> wrote:


Hi Arvin,

I would like to use some classes in the converted ruby code but I
have problems with function lookup.

I have figured out how to call functions (e.g. ArrangeButtons
from include/partitioning/ep-lib.rb in my class method by using
"module_function :ArrangeButtons" in ep-lib.rb. The problem now
is that the method deep_copy cannot be found inside

OK, I think there is needed some explanations.
At first link to explanation how modules works in ruby

With this background information it is easy to see where is your
problem. We convert includes to mixins and such mixins depends on
methods in given class, especially on other mixins in Client or
Module [1]. And you want to use Module just like namespace for method,
but such namespace doesn't have given methods.

It works if I use "include PartitioningEpLibInclude" inside my
class but I don't like to extend the classes with lots of general
utility functions.

So what's the correct way here?

Well, I check such method and you can remove deep copy as ret is newly
generated and buttons is not modified, so you can pass it as reference.
Just note that if you use another method for module you also need to
make it available, but it is not this case.

But for me correct way is to move it outside. So you can create in lib
directory something like storage/ui_ext.rb

Then have there something like:

module Yast
module UI
def self.ArrangeButtons buttons

and in your code then
require "storage/ui_ext"

module Yast
class Foo
def m

This show nice ruby feature, that allows extend classes. Of course
another solution can be add it directly ui bindings or if you find it
useful, I can add it to ruby bindings, so everyone can use it.

If you have another issue or if something is not clear do not hesitate
to ask. I can also provide more links that explain how ruby works.

Attached is a patch.

The error message is:

Client call failed with undefined method `deep_copy' for
Yast::PartitioningEpLibInclude:Module and backtrace
`create'", ...

ciao Arvin

To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: yast-devel+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups