Mailinglist Archive: yast-devel (144 mails)

< Previous Next >
Re: [yast-devel] Help: Lost in Ruby
On Tue, Aug 20, 2013 at 11:15:12AM +0200, Josef Reidinger wrote:

Arvin Schnell <aschnell@xxxxxxx> wrote:

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
ArrangeButtons.


OK, I think there is needed some explanations.
At first link to explanation how modules works in ruby
http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_modules.html

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.

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
...
end
end
end

and in your code then
require "storage/ui_ext"

module Yast
class Foo
def m
UI.ArrangeButtons
end
end
end

But this requires moving more or less all files and functions of
the expert partitioner around as I already replied to
Martin. It's simply not worth the effort (and new bugs) -
remember that all I want is to use existing functions from class
functions without polluting the classes through mixin.

Regards,
Arvin

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

< Previous Next >
Follow Ups